Commit 7ba295d7 authored by hrchilds's avatar hrchilds
Browse files

Update from July 27, 2004

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@288 18c085ea-50e0-402c-830e-de6fd14e8384
parent 4b3cb34b
......@@ -2,18 +2,10 @@
#define VISIT_MAP_TYPES_H
#include <string>
#include <vectortypes.h>
#ifdef WIN32
// Use VisIt's map class.
#include <VisItMap.h>
typedef VisItMap<std::string, int> StringIntMap;
typedef StringIntMap LevelColorMap;
typedef VisItMap<std::string, stringVector> StringStringVectorMap;
#else
#include <map>
typedef std::map<std::string, int> StringIntMap;
typedef StringIntMap LevelColorMap;
typedef std::map<std::string, stringVector> StringStringVectorMap;
#endif
#endif
......@@ -21,7 +21,7 @@
#include <avtCallback.h>
#include <avtSourceFromImage.h>
#include <BadWindowModeException.h>
#include <ImproperUseException.h>
#include <DebugStream.h>
#include <TimingsManager.h>
......@@ -652,6 +652,60 @@ VisWinRendering::Realize(void)
}
}
// ****************************************************************************
// Method: VisWinRendering::GetCaptureRegion
//
// Purpose:
// Computes the size of the region to capture based in image mode and
// request to do the viewport only or not
//
// Programmer: Mark C. Miller
// Creation: July 26, 2004
//
// ****************************************************************************
void
VisWinRendering::GetCaptureRegion(int& r0, int& c0, int& w, int& h,
bool doViewportOnly)
{
vtkRenderWindow *renWin = GetRenderWindow();
r0 = 0;
c0 = 0;
w = renWin->GetSize()[0];
h = renWin->GetSize()[1];
if (doViewportOnly)
{
bool haveViewport = false;
double viewPort[4];
if (mediator.GetMode() == WINMODE_2D)
{
VisWindow *vw = mediator;
avtView2D v = vw->GetView2D();
v.GetActualViewport(viewPort, w, h);
haveViewport = true;
}
else if (mediator.GetMode() == WINMODE_CURVE)
{
VisWindow *vw = mediator;
avtViewCurve v = vw->GetViewCurve();
v.GetViewport(viewPort);
haveViewport = true;
}
if (haveViewport)
{
int neww = (int) ((viewPort[1] - viewPort[0]) * w + 0.5);
int newh = (int) ((viewPort[3] - viewPort[2]) * h + 0.5);
c0 = (int) (viewPort[0] * w + 0.5);
r0 = (int) (viewPort[2] * h + 0.5);
w = neww;
h = newh;
}
}
}
// ****************************************************************************
// Method: VisWinRendering::ScreenCapture
......@@ -693,6 +747,12 @@ VisWinRendering::Realize(void)
// Fixed problem where used 2D view to control region selection for
// window in CURVE mode
//
// Mark C. Miller, Mon Jul 26 15:08:39 PDT 2004
// Moved code to compute size and origin of region to capture to
// GetCaptureRegion. Also, changed code to instead of swaping canvase
// and foreground layer order to just remove foreground layer and re-add
// it at the end.
//
// ****************************************************************************
avtImage_p
......@@ -706,10 +766,10 @@ VisWinRendering::ScreenCapture(bool doViewportOnly, bool doCanvasZBufferToo)
{
//
// If we want zbuffer for the canvas, we need to take care that
// the canvas is rendered last
// the canvas is rendered last. To achieve this, we temporarily
// remove the foreground renderer.
//
foreground->SetLayer(1);
canvas->SetLayer(0);
renWin->RemoveRenderer(foreground);
}
//
......@@ -720,41 +780,8 @@ VisWinRendering::ScreenCapture(bool doViewportOnly, bool doCanvasZBufferToo)
//
// Set region origin/size to be captured
//
int c0 = 0;
int r0 = 0;
int w = renWin->GetSize()[0];
int h = renWin->GetSize()[1];
if (doViewportOnly)
{
bool haveViewport = false;
double viewPort[4];
if (mediator.GetMode() == WINMODE_2D)
{
VisWindow *vw = mediator;
avtView2D v = vw->GetView2D();
v.GetActualViewport(viewPort, w, h);
haveViewport = true;
}
else if (mediator.GetMode() == WINMODE_CURVE)
{
VisWindow *vw = mediator;
avtViewCurve v = vw->GetViewCurve();
v.GetViewport(viewPort);
haveViewport = true;
}
if (haveViewport)
{
int neww = (int) ((viewPort[1] - viewPort[0]) * w + 0.5);
int newh = (int) ((viewPort[3] - viewPort[2]) * h + 0.5);
c0 = (int) (viewPort[0] * w + 0.5);
r0 = (int) (viewPort[2] * h + 0.5);
w = neww;
h = newh;
}
}
int r0, c0, w, h;
GetCaptureRegion(r0, c0, w, h, doViewportOnly);
if (doCanvasZBufferToo)
{
......@@ -791,13 +818,12 @@ VisWinRendering::ScreenCapture(bool doViewportOnly, bool doCanvasZBufferToo)
image->Delete();
//
// If we swapped the foreground & canvas layers to get the canvas' zbuffer,
// swap them back before we leave
// If we removed the foreground layers to get the canvas' zbuffer,
// put it back before we leave
//
if (doCanvasZBufferToo)
{
canvas->SetLayer(1);
foreground->SetLayer(0);
renWin->AddRenderer(foreground);
if (extRequestMode)
mediator.EnableExternalRenderRequests();
}
......@@ -805,6 +831,89 @@ VisWinRendering::ScreenCapture(bool doViewportOnly, bool doCanvasZBufferToo)
return img;
}
// ****************************************************************************
// Method: VisWinRendering::PostProcessScreenCapture
//
// Purpose:
// Does any necessary post-processing on a screen captured image. This
// is necessary when the engine is doing ALL rendering as in a
// non-"Screen Capture" (GUI terminology) save window that includes any
// annotations that are rendered in the foreground layer. Ordinarily,
// the engine never renders the foreground layer and it can only do so
// correctly after it has done a parallel image composite.
//
// Programmer: Mark C. Miller
// Creation: July 26, 2004
//
// ****************************************************************************
avtImage_p
VisWinRendering::PostProcessScreenCapture(avtImage_p capturedImage,
bool doViewportOnly)
{
unsigned char *pixels;
int useFrontBuffer = 1;
vtkRenderWindow *renWin = GetRenderWindow();
// compute size of region we'll be writing back to the frame buffer
int r0, c0, w, h;
GetCaptureRegion(r0, c0, w, h, doViewportOnly);
// confirm image passed in is the correct size
int iw, ih;
capturedImage->GetSize(&iw, &ih);
if ((iw != w) || (ih != h))
{
EXCEPTION1(ImproperUseException, "size of image passed for "
"PostProcessScreenCapture does not match vtkRenderWindow size");
}
// set pixel data
// Note that there appears to be a bug in VTK's implementation of the
// vtkRenderWindow::SetPixelData method such that the *first* call to
// set pixel data does NOT write to the correct portion of the framebuffer.
// However, succeeding calls do. So, as a work-around, we have an additional
// dummy call to SetPixelData.
pixels = capturedImage->GetImage().GetRGBBuffer();
renWin->SetPixelData(0, 0, 0, 0, pixels, useFrontBuffer); // Why? See above.
renWin->SetPixelData(c0, r0, c0+w-1, r0+h-1, pixels, useFrontBuffer);
// temporarily remove canvas and background renderers
renWin->RemoveRenderer(canvas);
renWin->RemoveRenderer(background);
// render (foreground layer only)
renWin->Render();
// capture the whole image now
GetCaptureRegion(r0, c0, w, h, false);
pixels = renWin->GetPixelData(c0,r0,c0+w-1,r0+h-1, useFrontBuffer);
// add canvas and background renderers back in
renWin->AddRenderer(background);
renWin->AddRenderer(canvas);
// return new image
vtkImageData *image = avtImageRepresentation::NewImage(w, h);
unsigned char *img_pix = (unsigned char *)image->GetScalarPointer(0, 0, 0);
memcpy(img_pix, pixels, 3*w*h);
delete [] pixels;
//
// Force some updates so we can let screenCaptureSource be destructed.
// The img->Update forces the window to render, so we explicitly
// disable external render requests
//
avtSourceFromImage screenCaptureSource(image);
avtImage_p img = screenCaptureSource.GetTypedOutput();
img->Update(screenCaptureSource.GetGeneralPipelineSpecification());
img->SetSource(NULL);
image->Delete();
return img;
}
// ****************************************************************************
// Method: VisWinRendering::SetSize
......
......@@ -120,6 +120,9 @@ class VisWindowColleagueProxy;
// Added data members for same.
// Elminated call to SetScalableThreshold.
//
// Mark C. Miller, Mon Jul 26 15:08:39 PDT 2004
// Added GetCaptureRegion() and PostProcessScreenCapture() methods
//
// ****************************************************************************
class VISWINDOW_API VisWinRendering : public VisWinColleague
......@@ -149,8 +152,13 @@ class VISWINDOW_API VisWinRendering : public VisWinColleague
virtual void MotionEnd(void);
void Realize(void);
void GetCaptureRegion(int& r0, int& c0, int& w, int& h,
bool doViewportOnly);
avtImage_p ScreenCapture(bool doViewportOnly = false,
bool doCanvasZBufferToo = false);
avtImage_p PostProcessScreenCapture(avtImage_p capturedImage,
bool doViewportOnly);
void SetSize(int, int);
void GetSize(int&, int&);
......
......@@ -1610,6 +1610,23 @@ VisWindow::ScreenCapture(bool doViewportOnly, bool doZBufferToo)
return rendering->ScreenCapture(doViewportOnly, doZBufferToo);
}
// ****************************************************************************
// Method: VisWindow::PostProcessScreenCapture
//
// Purpose:
// Does any necessary post-processing on a screen captured image. See
// comments in VisWinRendering.C for more details
//
// Programmer: Mark C. Miller
// Creation: July 26, 2004
//
// ****************************************************************************
avtImage_p
VisWindow::PostProcessScreenCapture(avtImage_p capturedImage, bool doViewportOnly)
{
return rendering->PostProcessScreenCapture(capturedImage, doViewportOnly);
}
// ****************************************************************************
// Method: VisWindow::GetAllDatasets
......
......@@ -261,6 +261,9 @@ class VisitInteractor;
// Added GetVisualCues and changes interface to QueryIsValid, UpdateQuery,
// DeleteQuery to use VisualCueInfo
//
// Mark C. Miller, Mon Jul 26 15:08:39 PDT 2004
// Added PostProcessScreenCapture
//
// ****************************************************************************
class VISWINDOW_API VisWindow
......@@ -280,6 +283,8 @@ public:
void Realize(void);
avtImage_p ScreenCapture(bool doViewportOnly = false,
bool doZBufferToo = false);
avtImage_p PostProcessScreenCapture(avtImage_p capturedImage,
bool doViewportOnly);
avtDataset_p GetAllDatasets(void);
void SetSize(int, int);
......
......@@ -647,6 +647,9 @@ RPCExecutor<StartPickRPC>::Execute(StartPickRPC *rpc)
// Mark C. Miller, Wed Jun 9 17:44:38 PDT 2004
// Added code to pass visual cue list along
//
// Mark C. Miller, Tue Jul 27 15:11:11 PDT 2004
// Added code to pass frame and state info along
//
// ****************************************************************************
template<>
void
......@@ -664,7 +667,8 @@ RPCExecutor<SetWinAnnotAttsRPC>::Execute(SetWinAnnotAttsRPC *rpc)
rpc->GetExtentTypeString());
netmgr->SetAnnotationAttributes(rpc->GetAnnotationAtts(),
rpc->GetAnnotationObjectList(),
rpc->GetVisualCueList());
rpc->GetVisualCueList(),
rpc->GetFrameAndState());
rpc->SendReply();
}
CATCH2(VisItException, e)
......
......@@ -1381,6 +1381,12 @@ NetworkManager::GetOutput(bool respondWithNullData, bool calledForRender)
// added plots. Moved test for exceeding scalable threshold to after point
// where each plot's network output is actually computed.
//
// Mark C. Miller, Mon Jul 26 15:08:39 PDT 2004
// Added code to post process the composited image when the engine
// is doing more than just 3D annotations. Fixed bug in determination of
// viewportedMode bool. Added code to pass frame and state info to
// set Win/Annot atts.
//
// ****************************************************************************
avtDataObjectWriter_p
NetworkManager::Render(intVector plotIds, bool getZBuffer, bool do3DAnnotsOnly)
......@@ -1475,7 +1481,6 @@ NetworkManager::Render(intVector plotIds, bool getZBuffer, bool do3DAnnotsOnly)
plotsCurrentlyInWindow = plotIds;
visitTimer->StopTimer(t2, "Setting up window contents");
}
int scalableThreshold = GetScalableThreshold();
......@@ -1552,7 +1557,8 @@ NetworkManager::Render(intVector plotIds, bool getZBuffer, bool do3DAnnotsOnly)
if (!do3DAnnotsOnly)
{
SetAnnotationAttributes(annotationAttributes,
annotationObjectList, visualCueList, false);
annotationObjectList, visualCueList,
frameAndState, false);
}
debug5 << "Rendering " << viswin->GetNumTriangles() << " triangles. "
......@@ -1561,9 +1567,9 @@ NetworkManager::Render(intVector plotIds, bool getZBuffer, bool do3DAnnotsOnly)
// render the image and capture it. Relies upon explicit render
int t3 = visitTimer->StartTimer();
bool viewportedMode = do3DAnnotsOnly &&
(viswin->GetWindowMode() == WINMODE_2D ||
viswin->GetWindowMode() == WINMODE_CURVE);
bool viewportedMode = !do3DAnnotsOnly ||
(viswin->GetWindowMode() == WINMODE_2D) ||
(viswin->GetWindowMode() == WINMODE_CURVE);
avtImage_p theImage = viswin->ScreenCapture(viewportedMode, true);
visitTimer->StopTimer(t3, "Screen capture for SR");
......@@ -1613,6 +1619,23 @@ NetworkManager::Render(intVector plotIds, bool getZBuffer, bool do3DAnnotsOnly)
//
imageCompositer.Execute();
avtDataObject_p compositedImageAsDataObject = imageCompositer.GetOutput();
//
// If the engine is doing more than just 3D attributes,
// post-process the composited image.
//
#ifdef PARALLEL
if (!do3DAnnotsOnly && (PAR_Rank() == 0))
#else
if (!do3DAnnotsOnly)
#endif
{
avtImage_p compositedImage;
CopyTo(compositedImage, compositedImageAsDataObject);
avtImage_p postProcessedImage =
viswin->PostProcessScreenCapture(compositedImage, viewportedMode);
CopyTo(compositedImageAsDataObject, postProcessedImage);
}
writer = compositedImageAsDataObject->InstantiateWriter();
writer->SetInput(compositedImageAsDataObject);
......@@ -1815,11 +1838,15 @@ NetworkManager::SetWindowAttributes(const WindowAttributes &atts,
//
// Mark C. Miller, Wed Jun 9 17:44:38 PDT 2004
// Added code to deal with VisualCueList
//
// Mark C. Miller, Tue Jul 27 15:11:11 PDT 2004
// Added code to deal with frame and state in VisWindow for
// AnnotationObjects
// ****************************************************************************
void
NetworkManager::SetAnnotationAttributes(const AnnotationAttributes &atts,
const AnnotationObjectList &aolist, const VisualCueList &visCues,
bool do3DAnnotsOnly)
const int *fns, bool do3DAnnotsOnly)
{
int i;
......@@ -1837,6 +1864,15 @@ NetworkManager::SetAnnotationAttributes(const AnnotationAttributes &atts,
newAtts.SetLegendInfoFlag(false);
newAtts.SetTriadFlag(false);
newAtts.SetAxesFlag2D(false);
viswin->DeleteAllAnnotationObjects();
}
else
{
viswin->DeleteAllAnnotationObjects();
viswin->CreateAnnotationObjectsFromList(aolist);
viswin->SetFrameAndState(fns[0],
fns[1],fns[2],fns[3],
fns[4],fns[5],fns[6]);
}
viswin->SetAnnotationAtts(&newAtts);
......@@ -1864,20 +1900,13 @@ NetworkManager::SetAnnotationAttributes(const AnnotationAttributes &atts,
}
}
}
if (do3DAnnotsOnly)
viswin->DeleteAllAnnotationObjects();
else
{
viswin->DeleteAllAnnotationObjects();
viswin->CreateAnnotationObjectsFromList(aolist);
}
}
annotationAttributes = atts;
annotationObjectList = aolist;
visualCueList = visCues;
for (i = 0; i < sizeof(frameAndState)/sizeof(frameAndState[0]); i++)
frameAndState[i] = fns[i];
}
......
......@@ -169,6 +169,10 @@ class VisWindow;
// Mark C. Miller, Wed Jun 9 17:44:38 PDT 2004
// Added visualCueList data member and arg to SetAnnotationAttributes
//
// Mark C. Miller, Tue Jul 27 15:11:11 PDT 2004
// Added frameAndState data member and associated arg to
// SetAnnotationAttributes
//
// ****************************************************************************
class NetworkManager
{
......@@ -211,6 +215,7 @@ class NetworkManager
void SetAnnotationAttributes(const AnnotationAttributes&,
const AnnotationObjectList&,
const VisualCueList&,
const int *fns,
bool do3DAnnotsOnly = true);
void SetLoadBalancer(LoadBalancer *lb) {loadBalancer = lb;};
......@@ -253,6 +258,7 @@ class NetworkManager
AnnotationObjectList annotationObjectList;
VisualCueList visualCueList;
std::string extentTypeString;
int frameAndState[7];
VisWindow *viswin;
std::vector<int> plotsCurrentlyInWindow;
......
......@@ -487,6 +487,9 @@ EngineProxy::UpdatePlotAttributes(const string &name, int id,
// Mark C. Miller, Wed Jun 9 17:44:38 PDT 2004
// Added arguement for visual cues
//
// Mark C. Miller, Tue Jul 27 15:11:11 PDT 2004
// Added argument for frame and state
//
// ****************************************************************************
void
......@@ -494,9 +497,11 @@ EngineProxy::SetWinAnnotAtts(const WindowAttributes *winAtts,
const AnnotationAttributes *annotAtts,
const AnnotationObjectList *aoList,
const string extStr,
const VisualCueList *visCues)
const VisualCueList *visCues,
const int *frameAndState)
{
setWinAnnotAttsRPC(winAtts, annotAtts, aoList, extStr, visCues);
setWinAnnotAttsRPC(winAtts, annotAtts, aoList, extStr, visCues,
frameAndState);
if (setWinAnnotAttsRPC.GetStatus() == VisItRPC::error)
{
RECONSTITUTE_EXCEPTION(setWinAnnotAttsRPC.GetExceptionType(),
......
......@@ -194,6 +194,9 @@ class StatusAttributes;
//
// Mark C. Miller, Mon Jul 12 19:46:32 PDT 2004
// Removed waitCB and cbData arguments from Render method
//
// Mark C. Miller, Tue Jul 27 15:11:11 PDT 2004
// Added argument for frame and state to SetWinAnnotAtts
//
// ****************************************************************************
......@@ -248,7 +251,8 @@ public:
const AnnotationAttributes*,
const AnnotationObjectList*,
std::string,
const VisualCueList*);
const VisualCueList*,
const int *frameAndState);
avtDataObjectReader_p Render(bool, const intVector&, bool);
......
......@@ -24,9 +24,12 @@
// Mark C. Miller, Wed Jun 9 17:44:38 PDT 2004
// Added data member for VisualCueList
//
// Mark C. Miller, Tue Jul 27 15:11:11 PDT 2004
// Added stuff to support frame and state info
//
// ****************************************************************************
SetWinAnnotAttsRPC::SetWinAnnotAttsRPC() : BlockingRPC("aaasa")
SetWinAnnotAttsRPC::SetWinAnnotAttsRPC() : BlockingRPC("aaasaI")
{
}
......@@ -70,6 +73,10 @@ SetWinAnnotAttsRPC::~SetWinAnnotAttsRPC()
//
// Mark C. Miller, Wed Jun 9 17:44:38 PDT 2004
// Added arg for VisualCueList
//
// Mark C. Miller, Tue Jul 27 15:11:11 PDT 2004
// Added stuff to support frame and state info
//
// ****************************************************************************
void
......@@ -77,7 +84,8 @@ SetWinAnnotAttsRPC::operator()(const WindowAttributes *winAtts,
const AnnotationAttributes *annotAtts,
const AnnotationObjectList *aoList,
const string extStr,
const VisualCueList *cueList)
const VisualCueList *cueList,
const int *frameAndState)
{
if (winAtts)
SetWindowAtts(winAtts);
......@@ -94,7 +102,11 @@ SetWinAnnotAttsRPC::operator()(const WindowAttributes *winAtts,
if (cueList)
SetVisualCueList(cueList);
if (winAtts || annotAtts || aoList || extStr.size() || cueList)
if (frameAndState)
SetFrameAndState(frameAndState);
if (winAtts || annotAtts || aoList || extStr.size() || cueList ||
frameAndState)
Execute();
}
......@@ -116,6 +128,9 @@ SetWinAnnotAttsRPC::operator()(const WindowAttributes *winAtts,
//
// Mark C. Miller, Wed Jun 9 17:44:38 PDT 2004
// Added visual cue list data member
//
// Mark C. Miller, Tue Jul 27 15:11:11 PDT 2004
// Added stuff to support frame and state info
// ****************************************************************************
void
......@@ -126,6 +141,7 @@ SetWinAnnotAttsRPC::SelectAll()
Select(2, (void*)&aolist);
Select(3, (void*)&extstr);
Select(4, (void*)&cuelist);
Select(5, (void*)fands, sizeof(fands)/sizeof(fands[0]));
}
......@@ -228,6 +244,22 @@ SetWinAnnotAttsRPC::SetVisualCueList(const VisualCueList* cueList)
Select(4,(void*)&cuelist);
}