Skip to content

Commit

Permalink
fixes for 1d animation.
Browse files Browse the repository at this point in the history
  • Loading branch information
vebeckner committed Jun 29, 2017
1 parent 060b2b0 commit 39b2ccd
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 26 deletions.
7 changes: 5 additions & 2 deletions AmrPicture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ AmrPicture::AmrPicture(GraphicsAttributes *gaptr,
subcutY = hLine;
subcut2ndY = hLine;

#if (BL_SPACEDIM == 2 || BL_SPACEDIM == 1)
#if (BL_SPACEDIM != 3)
slice = 0;
#else
slice = subDomain[maxAllowableLevel].smallEnd(Amrvis::YZ-myView);
Expand Down Expand Up @@ -372,8 +372,9 @@ void AmrPicture::AmrPictureInit() {
}
for(iLevel = minDrawnLevel; iLevel <= maxAllowableLevel; ++iLevel) {
imageData[iLevel] = new unsigned char[dataSize[iLevel]];
//scaledImageData[iLevel] = (unsigned char *) malloc(imageSize);
BL_ASSERT(imageData[iLevel] != nullptr);
scaledImageData[iLevel] = new unsigned char[imageSize];
BL_ASSERT(scaledImageData[iLevel] != nullptr);
}
//scaledImageDataBodyMask = nullptr;

Expand Down Expand Up @@ -496,6 +497,7 @@ void AmrPicture::SetSlice(int view, int here) {
cerr << endl;

imageData[lev] = new unsigned char[sliceBox[lev].numPts()];
BL_ASSERT(imageData[lev] != nullptr);
}
sliceFab[lev]->resize(sliceBox[lev], 1);
if(dataServicesPtr->AmrDataRef().CartGrid()) {
Expand Down Expand Up @@ -1437,6 +1439,7 @@ void AmrPicture::APChangeScale(int newScale, int previousScale) {
bool bCreateMask(iLevel == minDrawnLevel);
delete [] scaledImageData[iLevel];
scaledImageData[iLevel] = new unsigned char[imageSize];
BL_ASSERT(scaledImageData[iLevel] != nullptr);
CreateScaledImage(&xImageArray[iLevel], newScale *
AVGlobals::CRRBetweenLevels(iLevel, maxAllowableLevel,
amrData.RefRatio()),
Expand Down
6 changes: 3 additions & 3 deletions GlobalUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ void PrintUsage(char *exname) {
//cout << " [-bw n] " << endl;
cout << " [-maxpixmapsize <max picture size in # of pixels>]" << endl;
cout << " [-xslice n] [-yslice n] [-zslice n] [-sliceallvars]" << endl;
# if (BL_SPACEDIM == 2)
# if (BL_SPACEDIM != 3)
cout << " [-boxslice xlo ylo xhi yhi]" << endl;
cout << " [-a]" << endl;
cout << " [-setvelnames xname yname]" << endl;
Expand Down Expand Up @@ -591,7 +591,7 @@ void PrintUsage(char *exname) {
cout << " _box_ format: lox loy loz hix hiy hiz." << endl;
cout << " example: -boxslice 0 0 0 120 42 200." << endl;
cout << " Note: slices are written in batch mode." << endl;
#if(BL_SPACEDIM == 2)
#if(BL_SPACEDIM != 3)
cout << " -a load files as an animation." << endl;
cout << " -aa load files as an animation with annotations." << endl;
cout << " -anc load files as an animation, dont cache frames." << endl;
Expand Down Expand Up @@ -725,7 +725,7 @@ void AVGlobals::ParseCommandLine(int argc, char *argv[]) {
boxColor = atoi(argv[i+1]);
}
++i;
# if (BL_SPACEDIM == 2)
# if (BL_SPACEDIM != 3)
} else if(strcmp(argv[i],"-a") == 0) {
bAnimation = true;
bAnnotated = false;
Expand Down
20 changes: 12 additions & 8 deletions PltApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ PltApp::PltApp(XtAppContext app, Widget w, const string &filename,
if(AVGlobals::MaxPictureSize() == 0) {
maxAllowableScale = 1;
} else {
#if (BL_SPACEDIM == 1)
maxAllowableScale = (int) (exp2(14) / dataSize);
#else
maxAllowableScale = (int) sqrt((Real) (AVGlobals::MaxPictureSize() / dataSize));
#endif
}

int currentScale(max(1, min(GetInitialScale(), maxAllowableScale)));
Expand Down Expand Up @@ -1206,7 +1210,7 @@ void PltApp::PltAppInit(bool bSubVolume) {
}

#endif
int adjustHeight2D = (BL_SPACEDIM == 2) ? centerY : 0;
int adjustHeight2D = (BL_SPACEDIM != 3) ? centerY : 0;
Dimension slw;

if(animating2d) {
Expand Down Expand Up @@ -4446,7 +4450,7 @@ void PltApp::DoAnimFileScale(Widget, XtPointer, XtPointer cbs) {
void PltApp::ResetAnimation() {
StopAnimation();
if( ! interfaceReady) {
#if(BL_SPACEDIM == 2)
#if(BL_SPACEDIM != 3)
int maLev(pltAppState->MaxAllowableLevel());
AmrPicture *Tempap = amrPicturePtrArray[Amrvis::ZPLANE];
XtRemoveEventHandler(wPlotPlane[Amrvis::ZPLANE], ExposureMask, false,
Expand Down Expand Up @@ -4485,7 +4489,7 @@ void PltApp::StopAnimation() {
XtRemoveTimeOut(animationIId);
animationIId = 0;
}
#if (BL_SPACEDIM == 2)
#if (BL_SPACEDIM != 3)
for(int dim(0); dim < BL_SPACEDIM; ++dim) {
if(XYplotwin[dim]) {
XYplotwin[dim]->StopAnimation();
Expand All @@ -4500,8 +4504,8 @@ void PltApp::Animate(Amrvis::AnimDirection direction) {
StopAnimation();
animationIId = AddStaticTimeOut(frameSpeed, &PltApp::DoUpdateFrame);
animDirection = direction;
#if (BL_SPACEDIM == 2)
for(int dim(0); dim != 2; ++dim) {
#if (BL_SPACEDIM != 3)
for(int dim(0); dim != BL_SPACEDIM; ++dim) {
if(XYplotwin[dim]) {
XYplotwin[dim]->InitializeAnimation(currentFrame, animFrames);
}
Expand Down Expand Up @@ -4552,7 +4556,7 @@ void PltApp::ShowFrame() {
if( ! readyFrames[currentFrame] || datasetShowing || bSyncFrame ||
UsingFileRange(currentRangeType))
{
#if (BL_SPACEDIM == 2)
#if (BL_SPACEDIM != 3)
AmrPicture *tempapSF = amrPicturePtrArray[Amrvis::ZPLANE];
Array<Box> domain = amrPicturePtrArray[Amrvis::ZPLANE]->GetSubDomain();
XtRemoveEventHandler(wPlotPlane[Amrvis::ZPLANE], ExposureMask, false,
Expand Down Expand Up @@ -4637,8 +4641,8 @@ void PltApp::ShowFrame() {
this, pltAppState, hdir, vdir, sdir);
datasetPtr->DoExpose(false);
}
#if (BL_SPACEDIM == 2)
for(int dim(0); dim < 2; ++dim) {
#if (BL_SPACEDIM != 3)
for(int dim(0); dim < BL_SPACEDIM; ++dim) {
if(XYplotwin[dim]) {
XYplotwin[dim]->UpdateFrame(currentFrame);
}
Expand Down
18 changes: 17 additions & 1 deletion ProfApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,22 @@ void ProfApp::DoFuncList(Widget w, XtPointer client_data, XtPointer call_data)

String selection;
XmStringGetLtoR(cbs->item, XmSTRING_DEFAULT_CHARSET, &selection);
cout << "r selection = " << r << " " << selection << endl;

int itemCount(-1), selectedItemCount(-2), *positions;
XtVaGetValues(w, XmNitemCount, &itemCount,
XmNselectedItemCount, &selectedItemCount,
XmNselectedPositions, &positions,
NULL);
//int *positionList, positionCount;
//bool retVal = XmListGetSelectedPos(w, &positionList, &positionCount);
//if(retVal) {
cout << "r itemCount selectedItemCount positions[0] selection = " << r
<< " " << itemCount << " " << selectedItemCount << " "
<< positions[0] << " " << selection << endl;
//} else {
//cout << "**** no selected items." << endl;
//}

}


Expand Down Expand Up @@ -1014,6 +1029,7 @@ void ProfApp::GenerateFuncList(const Array<std::string> &funcs) {
strList[i] = XmStringCreateSimple(const_cast<char *>(funcs[i].c_str()));
}

SHOWVAL(numEntries);
XtVaSetValues(wFuncList,
XmNitemCount, numEntries,
XmNitems, strList,
Expand Down
12 changes: 6 additions & 6 deletions RegionPicture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void RegionPicture::APMakeImages(Palette *palptr) {
tempSliceFab.shift(Amrvis::YDIR, regionBaseHeight); // ---- for ati
sliceFab->setVal(tempSliceFab.min(0) - 1.0);
sliceFab->copy(tempSliceFab);
Real minUsing(tempSliceFab.min(0)), maxUsing(tempSliceFab.max(0));
Real minUsing(tempSliceFab.min(0)-1), maxUsing(tempSliceFab.max(0));

Box fullDomainBox(tempSliceFab.box());
Real subPercentLow(static_cast<Real>(subRegion.smallEnd(Amrvis::XDIR) -
Expand Down Expand Up @@ -269,11 +269,12 @@ void RegionPicture::CreateImage(const FArrayBox &fab, unsigned char *imagedata,
{
int jdsh, jtmp1;
int dIndex, iIndex;
Real gDiff(globalMax - globalMin);
Real oneOverGDiff;
if((globalMax - globalMin) < FLT_MIN) {
oneOverGDiff = 0.0;
} else {
oneOverGDiff = 1.0 / (globalMax - globalMin);
oneOverGDiff = 1.0 / gDiff;
}
const Real *dataPoint = fab.dataPtr();

Expand All @@ -282,15 +283,14 @@ void RegionPicture::CreateImage(const FArrayBox &fab, unsigned char *imagedata,
int paletteStart(palptr->PaletteStart());
int paletteEnd(palptr->PaletteEnd());
int colorSlots(palptr->ColorSlots());
int csm1(colorSlots - 1);
for(int j(0); j < datasizev; ++j) {
jdsh = j * datasizeh;
jtmp1 = (datasizev-j-1) * datasizeh;
for(int i(0); i < datasizeh; ++i) {
dIndex = i + jtmp1;
dPoint = dataPoint[dIndex];
if(dIndex >= fab.nPts()) {
cout << "**** dIndex fab.nPts() = " << dIndex << " " << fab.nPts() << endl;
if(dPoint < 0.0) {
dPoint = -2.0; // ---- set both background and ati to -2 (black in palette)
}
iIndex = i + jdsh;
if(dPoint > globalMax) { // clip
Expand All @@ -299,7 +299,7 @@ void RegionPicture::CreateImage(const FArrayBox &fab, unsigned char *imagedata,
imagedata[iIndex] = paletteStart;
} else {
imagedata[iIndex] = (unsigned char)
((((dPoint - globalMin) * oneOverGDiff) * csm1) );
((((dPoint - globalMin) * oneOverGDiff) * colorSlots) );
// ^^^^^^^^^^^^^^^^^^ Real data
imagedata[iIndex] += paletteStart;
}
Expand Down
6 changes: 3 additions & 3 deletions XYPlotWin.H
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ typedef struct {
bool drawQ;
int style, color;
Pixel pixel;
#if (BL_SPACEDIM == 2)
#if (BL_SPACEDIM != 3)
amrex::Array<::XYPlotDataList *> *anim_lists;
amrex::Array<char> *ready_list;
#endif
Expand All @@ -69,7 +69,7 @@ class XYPlotWin {
void AddDataList(::XYPlotDataList *new_list,
XYPlotLegendItem *insert_after = NULL);

#if (BL_SPACEDIM == 2)
#if (BL_SPACEDIM != 3)
void InitializeAnimation(int curr_frame, int num_frames);
void UpdateFrame(int frame);
void StopAnimation();
Expand Down Expand Up @@ -132,7 +132,7 @@ class XYPlotWin {
int iXOrgX, iXOrgY; // Origin of bounding box on screen
int iXOppX, iXOppY; // Other point defining bounding box
int iXLocWinX, iXLocWinY, iCurrHint;
#if (BL_SPACEDIM == 2)
#if (BL_SPACEDIM != 3)
int numFrames;
#endif
int currFrame;
Expand Down
6 changes: 3 additions & 3 deletions XYPlotWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ XYPlotWin::XYPlotWin(char *title, XtAppContext app, Widget w, PltApp *parent,
zoomedInQ = false;
saveDefaultQ = 0;
animatingQ = false;
#if (BL_SPACEDIM == 2)
#if (BL_SPACEDIM != 3)
currFrame = 0;
#endif

Expand Down Expand Up @@ -461,7 +461,7 @@ XYPlotWin::XYPlotWin(char *title, XtAppContext app, Widget w, PltApp *parent,
}


#if (BL_SPACEDIM == 2)
#if (BL_SPACEDIM != 3)
// -------------------------------------------------------------------
void XYPlotWin::InitializeAnimation(int curr_frame, int num_frames) {
if(animatingQ) {
Expand Down Expand Up @@ -1409,7 +1409,7 @@ void XYPlotWin::dotX(Widget win, int x, int y, int style, int color) {

// -------------------------------------------------------------------
void XYPlotWin::CBdoClearData(Widget, XtPointer, XtPointer) {
#if (BL_SPACEDIM == 2)
#if (BL_SPACEDIM != 3)
if(animatingQ) {
StopAnimation();
}
Expand Down

0 comments on commit 39b2ccd

Please sign in to comment.