diff --git a/AmrData.cpp b/AmrData.cpp index f3f7dc8..8e44948 100644 --- a/AmrData.cpp +++ b/AmrData.cpp @@ -1,6 +1,6 @@ // -// $Id: AmrData.cpp,v 1.65 2003-03-12 07:40:56 vince Exp $ +// $Id: AmrData.cpp,v 1.66 2004-04-16 23:50:43 vince Exp $ // // --------------------------------------------------------------- @@ -866,8 +866,23 @@ bool AmrData::ReadNonPlotfileData(const string &filename, FileType filetype) { zvMin = min(zvMin, tempVisMF.min(ic, iComp)); zvMax = max(zvMax, tempVisMF.max(ic, iComp)); } - levelZeroValue = zvMin - ((zvMax - zvMin) / 256.0); + levelZeroValue = zvMin; newfab->setVal(levelZeroValue); +#if(BL_SPACEDIM == 2) +#ifdef BL_SETMFBACKGROUND + Real *dptr = newfab->dataPtr(); + int idx; + for(int icr(0); icr < newfab->box().length(1); ++icr) { + for(int icc(0); icc < newfab->box().length(0); ++icc) { + idx = icc + (icr * newfab->box().length(0)); + BL_ASSERT(idx < newfab->box().numPts()); + if((icc + icr) % 5 == 0) { + dptr[idx] = zvMax; + } + } + } +#endif +#endif dataGrids[0][iComp]->setFab(0, newfab); dataGridsDefined[0][iComp][0] = true; diff --git a/AmrPicture.cpp b/AmrPicture.cpp index 125ecce..e30c53c 100644 --- a/AmrPicture.cpp +++ b/AmrPicture.cpp @@ -1,6 +1,6 @@ // -// $Id: AmrPicture.cpp,v 1.83 2003-12-18 23:32:53 vince Exp $ +// $Id: AmrPicture.cpp,v 1.84 2004-04-16 23:50:43 vince Exp $ // // --------------------------------------------------------------- @@ -25,15 +25,19 @@ using std::min; #include "ArrayView.H" #endif +// --------------------------------------------------------------------- bool DrawRaster(ContourType cType) { return (cType == RASTERONLY || cType == RASTERCONTOURS || cType == VECTORS); } +// --------------------------------------------------------------------- bool DrawContours(ContourType cType) { return (cType == RASTERCONTOURS || cType == COLORCONTOURS || cType == BWCONTOURS); } + +// --------------------------------------------------------------------- static bool UsingFileRange(const MinMaxRangeType rt) { return(rt == FILEGLOBALMINMAX || rt == FILESUBREGIONMINMAX || @@ -55,9 +59,7 @@ AmrPicture::AmrPicture(GraphicsAttributes *gaptr, isSubDomain(false) { int i, ilev; - const AmrData &amrData = dataServicesPtr->AmrDataRef(); - int maxAllowableLevel(pltAppStatePtr->MaxAllowableLevel()); numberOfLevels = maxAllowableLevel + 1; @@ -89,17 +91,45 @@ AmrPicture::AmrPicture(GraphicsAttributes *gaptr, dataSize[ilev] = dataSizeH[ilev] * dataSizeV[ilev]; // for a picture (slice). } - vLine = 0; - hLine = subDomain[maxAllowableLevel].bigEnd(YDIR) * - pltAppStatePtr->CurrentScale(); - subcutY = hLine; - subcut2ndY = hLine; + if(AVGlobals::GivenInitialPlanes()) { + BL_ASSERT(BL_SPACEDIM == 3); + int coarsenCRR = AVGlobals::CRRBetweenLevels(maxAllowableLevel, + pltAppStatePtr->FinestLevel(), + amrData.RefRatio()); + int tempSliceV = AVGlobals::GetInitialPlanes()[XDIR]; // at finest lev + int tempSliceH = AVGlobals::GetInitialPlanes()[YDIR]; // at finest lev + tempSliceV /= coarsenCRR; + tempSliceH /= coarsenCRR; + tempSliceH = subDomain[maxAllowableLevel].bigEnd(YDIR) - tempSliceH; + vLine = max(min(tempSliceV, + subDomain[maxAllowableLevel].bigEnd(XDIR)), + subDomain[maxAllowableLevel].smallEnd(XDIR)); + hLine = max(min(tempSliceH, + subDomain[maxAllowableLevel].bigEnd(YDIR)), + subDomain[maxAllowableLevel].smallEnd(YDIR)); + vLine *= pltAppStatePtr->CurrentScale(); + hLine *= pltAppStatePtr->CurrentScale(); + subcutY = hLine; + subcut2ndY = hLine; + + int tempSlice = AVGlobals::GetInitialPlanes()[YZ - myView]; // at finest lev + tempSlice /= coarsenCRR; + slice = max(min(tempSlice, + subDomain[maxAllowableLevel].bigEnd(YZ-myView)), + subDomain[maxAllowableLevel].smallEnd(YZ-myView)); + } else { + vLine = 0; + hLine = subDomain[maxAllowableLevel].bigEnd(YDIR) * + pltAppStatePtr->CurrentScale(); + subcutY = hLine; + subcut2ndY = hLine; #if (BL_SPACEDIM == 2) - slice = 0; + slice = 0; #else - slice = subDomain[maxAllowableLevel].smallEnd(YZ-myView); + slice = subDomain[maxAllowableLevel].smallEnd(YZ-myView); #endif + } sliceBox.resize(numberOfLevels); for(ilev = minDrawnLevel; ilev <= maxAllowableLevel; ilev++) { // set type @@ -168,24 +198,22 @@ AmrPicture::AmrPicture(int view, GraphicsAttributes *gaptr, } # if (BL_SPACEDIM == 3) - if(myView==XY) { hLine = (subDomain[maxAllowableLevel].bigEnd(YDIR) - subDomain[maxAllowableLevel].smallEnd(YDIR)) * pltAppStatePtr->CurrentScale(); vLine = 0; - } else if(myView==XZ) { + } else if(myView==XZ) { hLine = (subDomain[maxAllowableLevel].bigEnd(ZDIR) - subDomain[maxAllowableLevel].smallEnd(ZDIR)) * pltAppStatePtr->CurrentScale(); vLine = 0; - } else { + } else { hLine = (subDomain[maxAllowableLevel].bigEnd(ZDIR) - subDomain[maxAllowableLevel].smallEnd(ZDIR)) * pltAppStatePtr->CurrentScale(); vLine = 0; - } - + } if(parentPltAppPtr != NULL) { int tempSlice = parentPltAppPtr->GetAmrPicturePtr(myView)->GetSlice(); @@ -197,7 +225,59 @@ AmrPicture::AmrPicture(int view, GraphicsAttributes *gaptr, subDomain[maxAllowableLevel].bigEnd(YZ-myView)), subDomain[maxAllowableLevel].smallEnd(YZ-myView)); } else { - slice = subDomain[maxAllowableLevel].smallEnd(YZ-myView); + if(AVGlobals::GivenInitialPlanes()) { + int tempSlice = AVGlobals::GetInitialPlanes()[YZ - myView]; // finest lev + int coarsenCRR = AVGlobals::CRRBetweenLevels(maxAllowableLevel, + pltAppStatePtr->FinestLevel(), + amrData.RefRatio()); + tempSlice /= coarsenCRR; + slice = max(min(tempSlice, + subDomain[maxAllowableLevel].bigEnd(YZ-myView)), + subDomain[maxAllowableLevel].smallEnd(YZ-myView)); + + int tempSliceV, tempSliceH; + if(myView==XY) { + tempSliceV = AVGlobals::GetInitialPlanes()[XDIR]; // at finest lev + tempSliceH = AVGlobals::GetInitialPlanes()[YDIR]; // at finest lev + tempSliceV /= coarsenCRR; + tempSliceH /= coarsenCRR; + tempSliceH = subDomain[maxAllowableLevel].bigEnd(YDIR) - tempSliceH; + vLine = max(min(tempSliceV, + subDomain[maxAllowableLevel].bigEnd(XDIR)), + subDomain[maxAllowableLevel].smallEnd(XDIR)); + hLine = max(min(tempSliceH, + subDomain[maxAllowableLevel].bigEnd(YDIR)), + subDomain[maxAllowableLevel].smallEnd(YDIR)); + } else if(myView==XZ) { + tempSliceV = AVGlobals::GetInitialPlanes()[XDIR]; // at finest lev + tempSliceH = AVGlobals::GetInitialPlanes()[ZDIR]; // at finest lev + tempSliceV /= coarsenCRR; + tempSliceH /= coarsenCRR; + tempSliceH = subDomain[maxAllowableLevel].bigEnd(ZDIR) - tempSliceH; + vLine = max(min(tempSliceV, + subDomain[maxAllowableLevel].bigEnd(XDIR)), + subDomain[maxAllowableLevel].smallEnd(XDIR)); + hLine = max(min(tempSliceH, + subDomain[maxAllowableLevel].bigEnd(ZDIR)), + subDomain[maxAllowableLevel].smallEnd(ZDIR)); + } else { + tempSliceV = AVGlobals::GetInitialPlanes()[YDIR]; // at finest lev + tempSliceH = AVGlobals::GetInitialPlanes()[ZDIR]; // at finest lev + tempSliceV /= coarsenCRR; + tempSliceH /= coarsenCRR; + tempSliceH = subDomain[maxAllowableLevel].bigEnd(ZDIR) - tempSliceH; + vLine = max(min(tempSliceV, + subDomain[maxAllowableLevel].bigEnd(YDIR)), + subDomain[maxAllowableLevel].smallEnd(YDIR)); + hLine = max(min(tempSliceH, + subDomain[maxAllowableLevel].bigEnd(ZDIR)), + subDomain[maxAllowableLevel].smallEnd(ZDIR)); + } + vLine *= pltAppStatePtr->CurrentScale(); + hLine *= pltAppStatePtr->CurrentScale(); + } else { + slice = subDomain[maxAllowableLevel].smallEnd(YZ - myView); + } } # else diff --git a/AmrVisTool.cpp b/AmrVisTool.cpp index 8751d3d..2b4ba83 100644 --- a/AmrVisTool.cpp +++ b/AmrVisTool.cpp @@ -1,6 +1,6 @@ // -// $Id: AmrVisTool.cpp,v 1.63 2004-02-10 22:51:10 vince Exp $ +// $Id: AmrVisTool.cpp,v 1.64 2004-04-16 23:50:43 vince Exp $ // // --------------------------------------------------------------- @@ -428,6 +428,23 @@ void BatchFunctions() { } // end BatchFunctions + +// --------------------------------------------------------------- +void QuitAll() { + for(list::iterator li = pltAppList.begin(); + li != pltAppList.end(); ++li) + { + PltApp *obj = *li; + Array dataServicesPtr = obj->GetDataServicesPtrArray(); + for(int ids(0); ids < dataServicesPtr.size(); ++ids) { + dataServicesPtr[ids]->DecrementNumberOfUsers(); + } + delete obj; + } + pltAppList.clear(); + DataServices::Dispatch(DataServices::ExitRequest, NULL); +} + // --------------------------------------------------------------- void CBFileMenu(Widget, XtPointer client_data, XtPointer) { @@ -436,19 +453,8 @@ void CBFileMenu(Widget, XtPointer client_data, XtPointer) { unsigned long item = (unsigned long) client_data; if(item == QUITITEM) { - for(list::iterator li = pltAppList.begin(); - li != pltAppList.end(); ++li) { - PltApp *obj = *li; - Array dataServicesPtr = obj->GetDataServicesPtrArray(); - for(int ids(0); ids < dataServicesPtr.size(); ++ids) { - dataServicesPtr[ids]->DecrementNumberOfUsers(); - } - delete obj; - } - pltAppList.clear(); - DataServices::Dispatch(DataServices::ExitRequest, NULL); - } - if(item == OPENITEM) { + QuitAll(); + } else if(item == OPENITEM) { i = 0; FileType fileType(AVGlobals::GetDefaultFileType()); XmString sMask; @@ -566,5 +572,11 @@ void CBQuitPltApp(Widget ofPltApp, XtPointer client_data, XtPointer) { delete obj; } + + +// --------------------------------------------------------------- +void CBQuitAll(Widget, XtPointer, XtPointer) { + QuitAll(); +} // --------------------------------------------------------------- // --------------------------------------------------------------- diff --git a/Dataset.cpp b/Dataset.cpp index 0300f49..6c63793 100644 --- a/Dataset.cpp +++ b/Dataset.cpp @@ -1,6 +1,6 @@ // -// $Id: Dataset.cpp,v 1.52 2003-12-18 23:32:53 vince Exp $ +// $Id: Dataset.cpp,v 1.53 2004-04-16 23:50:43 vince Exp $ // // --------------------------------------------------------------- @@ -259,7 +259,7 @@ Dataset::~Dataset() { delete [] dataStringArray; if(bDataStringArrayAllocated) { BL_ASSERT(maxAllowableLevel == pltAppStatePtr->MaxAllowableLevel()); - for(int j = 0; j <= maxAllowableLevel; ++j) { + for(int j(0); j <= maxAllowableLevel; ++j) { delete [] myDataStringArray[j]; } delete [] myDataStringArray; @@ -274,7 +274,7 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr, int hdir, int vdir, int sdir) { int lev, i, c, d, stringCount; - Box temp, dataBox; + Box boxTemp, dataBox; Real *dataPoint; if(bDataStringArrayAllocated) { @@ -320,7 +320,7 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr, maxAllowableLevel = pltAppStatePtr->MaxAllowableLevel(); // set up datasetRegion - //we shall waste some space to that datasetRegion[lev] corresponds to lev + // we shall waste some space so that datasetRegion[lev] corresponds to lev datasetRegion = new Box[maxAllowableLevel + 1]; datasetRegion[maxAllowableLevel] = alignedRegion; for(i = maxAllowableLevel - 1; i >= 0; --i) { @@ -343,7 +343,6 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr, int paletteEnd(palptr->PaletteEnd()); char header[BUFSIZ]; - ostrstream outstr(header, sizeof(header)); outstr << AVGlobals::StripSlashes(pltAppPtr->GetFileName()) << " " << pltAppStatePtr->CurrentDerived() @@ -364,11 +363,11 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr, (void *) &(pltAppStatePtr->CurrentDerived())); for(int iBox(0); iBox < amrData.boxArray(lev).size(); ++iBox) { - temp = amrData.boxArray(lev)[iBox]; - if(datasetRegion[lev].intersects(temp)) { + boxTemp = amrData.boxArray(lev)[iBox]; + if(datasetRegion[lev].intersects(boxTemp)) { int ddl; - temp &= datasetRegion[lev]; - dataBox = temp; + boxTemp &= datasetRegion[lev]; + dataBox = boxTemp; FArrayBox dataFabTemp(dataBox, 1); dataFabTemp.copy(*(dataFab[lev])); dataPoint = dataFabTemp.dataPtr(); @@ -384,8 +383,21 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr, } } } + + // fix for cart grid body + bool bCartGrid(dataServicesPtr->AmrDataRef().CartGrid()); + bool bShowBody(AVGlobals::GetShowBody()); + const string vfDerived("vfrac"); + if(bCartGrid && pltAppStatePtr->CurrentDerived() != vfDerived && bShowBody) { + largestWidth = max(5, largestWidth); // for body string + } + + bool bIsMF(dataServicesPtr->GetFileType() == MULTIFAB); + if(bIsMF) { // fix level zero data + largestWidth = max(8, largestWidth); // for no data string + } + char levelInfo[15], maxInfo[20], minInfo[20], maxInfoV[25], minInfoV[25]; - sprintf(levelInfo, "Level: %i", maxDrawnLevel); XmString sNewLevel = XmStringCreateSimple(levelInfo); @@ -413,8 +425,7 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr, } numStrings = stringCount; dataStringArray = new StringLoc[numStrings]; - int ns; - for(ns = 0; ns < numStrings; ns++) { + for(int ns(0); ns < numStrings; ++ns) { dataStringArray[ns].olflag = maxDrawnLevel; } if(dataStringArray == NULL) { @@ -433,19 +444,19 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr, // determine the length of the character labels for the indices Real vItemCount((Real) (datasetRegion[maxDrawnLevel].bigEnd(vDIR))); - int vIndicesWidth((int) (ceil(log10(vItemCount+1)))); + int vIndicesWidth((int) (ceil(log10(vItemCount + 1)))); Real hItemCount((Real) (datasetRegion[maxDrawnLevel].bigEnd(hDIR))); - int hIndicesWidth((int) (ceil(log10(hItemCount+1)))); + int hIndicesWidth((int) (ceil(log10(hItemCount + 1)))); largestWidth = max(largestWidth, hIndicesWidth); - indexWidth = max(MAXINDEXCHARS, vIndicesWidth+1) * CHARACTERWIDTH; + indexWidth = max(MAXINDEXCHARS, vIndicesWidth + 1) * CHARACTERWIDTH; // determine size of data area dataItemWidth = largestWidth * CHARACTERWIDTH; - pixSizeX = datasetRegion[maxDrawnLevel].length(hDIR) * dataItemWidth - + ((maxDrawnLevel-minDrawnLevel+1)*indexWidth); - pixSizeY = datasetRegion[maxDrawnLevel].length(vDIR) * CHARACTERHEIGHT - + ((maxDrawnLevel-minDrawnLevel+1)*indexHeight); + pixSizeX = datasetRegion[maxDrawnLevel].length(hDIR) * dataItemWidth + + ((maxDrawnLevel - minDrawnLevel + 1) * indexWidth); + pixSizeY = datasetRegion[maxDrawnLevel].length(vDIR) * CHARACTERHEIGHT + + ((maxDrawnLevel - minDrawnLevel + 1) * indexHeight); // create StringLoc array and define color scheme if(pixSizeX == 0 || pixSizeY == 0) { @@ -476,18 +487,17 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr, } else { oneOverGlobalDiff = 1.0 / globalDiff; } - - + for(lev = minDrawnLevel; lev <= maxDrawnLevel; ++lev) { - for(int iBox = 0; iBox < amrData.boxArray(lev).size(); ++iBox) { - temp = amrData.boxArray(lev)[iBox]; - if(datasetRegion[lev].intersects(temp)) { - temp &= datasetRegion[lev]; - dataBox = temp; - temp.refine(AVGlobals::CRRBetweenLevels(lev, maxDrawnLevel, + for(int iBox(0); iBox < amrData.boxArray(lev).size(); ++iBox) { + boxTemp = amrData.boxArray(lev)[iBox]; + if(datasetRegion[lev].intersects(boxTemp)) { + boxTemp &= datasetRegion[lev]; + dataBox = boxTemp; + boxTemp.refine(AVGlobals::CRRBetweenLevels(lev, maxDrawnLevel, amrData.RefRatio())); - temp.shift(hDIR, -datasetRegion[maxDrawnLevel].smallEnd(hDIR)); - temp.shift(vDIR, -datasetRegion[maxDrawnLevel].smallEnd(vDIR)); + boxTemp.shift(hDIR, -datasetRegion[maxDrawnLevel].smallEnd(hDIR)); + boxTemp.shift(vDIR, -datasetRegion[maxDrawnLevel].smallEnd(vDIR)); FArrayBox dataFabTemp(dataBox, 1); dataFabTemp.copy(*(dataFab[lev])); dataPoint = dataFabTemp.dataPtr(); @@ -509,39 +519,88 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr, (((dataPoint[c+ddl] - datamin) * oneOverGlobalDiff) * csm1 ); dataStringArray[stringCount].color += paletteStart; } - dataStringArray[stringCount].xloc = (temp.smallEnd(hDIR) + dataStringArray[stringCount].xloc = (boxTemp.smallEnd(hDIR) + c * crr) * dataItemWidth + 5; dataStringArray[stringCount].yloc = pixSizeY-1 - - (temp.smallEnd(vDIR) + d * crr) * CHARACTERHEIGHT - 4; + (boxTemp.smallEnd(vDIR) + d * crr) * CHARACTERHEIGHT - 4; for(i = lastLevLow; i < lastLevHigh; ++i) { // remove overlap if(dataStringArray[i].xloc == dataStringArray[stringCount].xloc && dataStringArray[i].yloc == dataStringArray[stringCount].yloc) - { - dataStringArray[i].olflag = lev - 1; - // highest level at which visible - } + { + dataStringArray[i].olflag = lev - 1; + // highest level at which visible + } } strcpy(dataStringArray[stringCount].ds, dataString); dataStringArray[stringCount].dslen = strlen(dataString); + if(bIsMF && lev == 0) { // fix level zero data + strcpy(dataStringArray[stringCount].ds, "no data"); + dataStringArray[stringCount].dslen = strlen("no data"); + dataStringArray[stringCount].color = palptr->WhiteIndex(); + } + ++stringCount; } // end for(c...) } // end for(d...) - } // end if(datasetRegion[lev].intersects(temp)) + } // end if(datasetRegion[lev].intersects(boxTemp)) } lastLevLow = lastLevHigh; lastLevHigh = stringCount; } - - } // end if(pixSizeX...) - //now load into **StringLoc - + + // fix for cart grid body + if(bCartGrid && pltAppStatePtr->CurrentDerived() != vfDerived && bShowBody) { + int stringCountCG(0); + for(int lev(minDrawnLevel); lev <= maxDrawnLevel; ++lev) { + FArrayBox cgDataFab(datasetRegion[lev], 1); + Real vfeps = dataServicesPtr->AmrDataRef().VfEps(lev); + DataServices::Dispatch(DataServices::FillVarOneFab, dataServicesPtr, + (void *) &cgDataFab, + (void *) &(cgDataFab.box()), + lev, + (void *) &vfDerived); + + int crr = AVGlobals::CRRBetweenLevels(lev, maxDrawnLevel, + amrData.RefRatio()); + for(int iBox(0); iBox < amrData.boxArray(lev).size(); ++iBox) { + Box boxTemp = amrData.boxArray(lev)[iBox]; + if(datasetRegion[lev].intersects(boxTemp)) { + boxTemp &= datasetRegion[lev]; + Box dataBox(boxTemp); + boxTemp.refine(crr); + boxTemp.shift(hDIR, -datasetRegion[maxDrawnLevel].smallEnd(hDIR)); + boxTemp.shift(vDIR, -datasetRegion[maxDrawnLevel].smallEnd(vDIR)); + FArrayBox cgDataFabTemp(dataBox, 1); + cgDataFabTemp.copy(cgDataFab); + Real *dataPoint = cgDataFabTemp.dataPtr(); + + for(int d(0); d < dataBox.length(vDIR); ++d) { + int ddl(d * dataBox.length(hDIR)); + for(int c(0); c < dataBox.length(hDIR); ++c) { + if(dataPoint[c+ddl] < vfeps) { + dataStringArray[stringCountCG].color = palptr->WhiteIndex(); + strcpy(dataStringArray[stringCountCG].ds, "body"); + dataStringArray[stringCountCG].dslen = strlen("body"); + } + + ++stringCountCG; + + } // end for(c...) + } // end for(d...) + + } // end if(datasetRegion[lev].intersects(boxTemp)) + } + } + } + + // now load into **StringLoc int sCount(0); for(lev = minDrawnLevel; lev <= maxDrawnLevel; ++lev) { for(stringCount = 0; stringCount < myStringCount[lev]; ++stringCount) { @@ -549,8 +608,8 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr, ++sCount; } } - - + + XSetWindowColormap(gaPtr->PDisplay(), XtWindow(wDatasetTopLevel), pltAppPtr->GetPalettePtr()->GetColormap()); XSetWindowColormap(gaPtr->PDisplay(), XtWindow(wPixArea), @@ -579,7 +638,7 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr, amrData.RefRatio())); int boxSize(((int) (ceil(dBoxSize)-dBoxSize >= 0.5 ? floor(dBoxSize): ceil(dBoxSize)))); - int vStartPos((int) (fmod(double(datasetRegion[maxDrawnLevel].bigEnd(vDIR) + 1), + int vStartPos((int) (fmod(double(datasetRegion[maxDrawnLevel].bigEnd(vDIR)+1), double(boxSize)))); vStartPos = (vStartPos != 0 ? vStartPos - boxSize:vStartPos); // fill the box index arrays @@ -611,8 +670,8 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr, strcpy(vIndexArray[level][d].ds, dataString); vIndexArray[level][d].dslen = strlen(dataString); vIndexArray[level][d].olflag = false; - } // end for(d...) - } //end for(int level = minDrawnLevel...) + } + } for(i = 0; i < dataFab.size(); ++i) { delete dataFab[i]; @@ -1003,13 +1062,13 @@ void Dataset::DrawIndices() { const AmrData &amrData = dataServicesPtr->AmrDataRef(); for(int level = minDrawnLevel; level<= maxDrawnLevel; ++level) { - Box temp(datasetRegion[level]); + Box boxTemp(datasetRegion[level]); int count(level - minDrawnLevel); - temp.refine(AVGlobals::CRRBetweenLevels(level, maxDrawnLevel, + boxTemp.refine(AVGlobals::CRRBetweenLevels(level, maxDrawnLevel, amrData.RefRatio())); - temp.shift(hDIR, -datasetRegion[maxDrawnLevel].smallEnd(hDIR)); - temp.shift(vDIR, -datasetRegion[maxDrawnLevel].smallEnd(vDIR)); + boxTemp.shift(hDIR, -datasetRegion[maxDrawnLevel].smallEnd(hDIR)); + boxTemp.shift(vDIR, -datasetRegion[maxDrawnLevel].smallEnd(vDIR)); double dBoxSize((double) AVGlobals::CRRBetweenLevels(level, maxDrawnLevel, amrData.RefRatio())); @@ -1017,7 +1076,7 @@ void Dataset::DrawIndices() { (int) floor(dBoxSize): (int) ceil(dBoxSize))); // draw the horizontal box index grid -- on top of the white background. - DrawGrid(temp.smallEnd(hDIR) * dataItemWidth, + DrawGrid(boxTemp.smallEnd(hDIR) * dataItemWidth, hIndexAreaStart-(count*hIndexAreaHeight)-1, vIndexAreaStart-(count*vIndexAreaWidth), hIndexAreaEnd-(count*hIndexAreaHeight), diff --git a/GNUmakefile b/GNUmakefile index 4d1ae2e..7dd4b10 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,5 +1,5 @@ -PRECISION = FLOAT PRECISION = DOUBLE +PRECISION = FLOAT PROFILE = TRUE PROFILE = FALSE @@ -7,6 +7,7 @@ PROFILE = FALSE COMP = mpKCC COMP = KCC +COMP = Intel COMP = g++ FCOMP = Intel FCOMP = diff --git a/GlobalUtilities.H b/GlobalUtilities.H index 9347c7e..f656f26 100644 --- a/GlobalUtilities.H +++ b/GlobalUtilities.H @@ -1,6 +1,6 @@ // -// $Id: GlobalUtilities.H,v 1.20 2002-12-10 20:12:23 vince Exp $ +// $Id: GlobalUtilities.H,v 1.21 2004-04-16 23:50:43 vince Exp $ // // --------------------------------------------------------------- @@ -80,6 +80,8 @@ namespace AVGlobals { bool SliceAllVars(); Array< list > &GetDumpSlices(); int GetFabOutFormat(); + bool GivenInitialPlanes(); + IntVect GetInitialPlanes(); // -------------------- cartGrid functions void SetShowBody(const bool btf); diff --git a/GlobalUtilities.cpp b/GlobalUtilities.cpp index 54bf56c..9286f3f 100644 --- a/GlobalUtilities.cpp +++ b/GlobalUtilities.cpp @@ -1,6 +1,6 @@ // -// $Id: GlobalUtilities.cpp,v 1.50 2002-12-10 20:12:23 vince Exp $ +// $Id: GlobalUtilities.cpp,v 1.51 2004-04-16 23:50:43 vince Exp $ // // --------------------------------------------------------------- @@ -57,6 +57,8 @@ int maxPaletteIndex; bool SGIrgbfile(true); int fabIOSize; bool bShowBody(true); +bool givenInitialPlanes(false); +IntVect ivInitialPlanes; char *FileTypeString[] = { "invalidtype", "fab", "multifab", "newplt" @@ -304,6 +306,10 @@ void AVGlobals::GetDefaults(const string &defaultsFile) { sscanf(buffer, "%s%d", defaultString, &tempInt); PltApp::SetInitialScale(tempInt); } + else if(strcmp(defaultString, "maxmenuitems") == 0) { + sscanf(buffer, "%s%d", defaultString, &tempInt); + PltApp::SetInitialMaxMenuItems(tempInt); + } else if(strcmp(defaultString, "numberformat") == 0) { sscanf(buffer, "%s%s", defaultString, tempString); PltApp::SetInitialFormatString(tempString); @@ -423,7 +429,7 @@ void PrintUsage(char *exname) { cout << " [-fabiosize nbits]" << endl; cout << " [-maxlev n]" << endl; cout << " [-palette palname] [-initialderived dername]" << endl; - cout << " [-lightingfile name]" << endl; + cout << " [-lightingfile name] [-maxmenuitems n]" << endl; cout << " [-initialscale n] [-showboxes tf] [-numberformat fmt]" << endl; cout << " [-lowblack] [-showbody tf]"<< endl; cout << " [-cliptoppalette]"<< endl; @@ -436,6 +442,7 @@ void PrintUsage(char *exname) { cout << " [-makeswf_value]" << endl; #endif cout << " [-useminmax min max]" << endl; + cout << " [-initplanes xp yp zp]" << endl; #endif cout << " []" << endl; cout << endl; @@ -472,6 +479,7 @@ void PrintUsage(char *exname) { cout << " -maxlev n specify the maximum drawn level." << endl; cout << " -palette palname set the initial palette." << endl; cout << " -lightingfile name set the initial lighting parameter file." << endl; + cout << " -maxmenuitems n set the max menu items per column to n." << endl; cout << " -initialderived dername set the initial derived to dername." << endl; cout << " -initialscale n set the initial scale to n." << endl; cout << " -showboxes tf show boxes (the value of tf is true or false)." << endl; @@ -489,7 +497,8 @@ void PrintUsage(char *exname) { << " note: works in batch mode." << endl; cout << " -makeswf_value same as above, with value model rendering."< must be included if box is specified." << endl; cout << endl; @@ -500,14 +509,13 @@ void PrintUsage(char *exname) { // ------------------------------------------------------------------- void AVGlobals::ParseCommandLine(int argc, char *argv[]) { - char clsx[10]; - char clsy[10]; - char clbx[10]; - char clby[10]; + char clsx[32], clsy[32]; + char clbx[32], clby[32]; #if (BL_SPACEDIM == 3) - char clsz[10]; - char clbz[10]; + char clsz[32]; + char clbz[32]; + char clPlaneX[32], clPlaneY[32], clPlaneZ[32]; #endif givenFilename = false; @@ -674,7 +682,7 @@ void AVGlobals::ParseCommandLine(int argc, char *argv[]) { } ++i; } else if(strcmp(argv[i], "-boxslice") == 0) { -# if (BL_SPACEDIM == 2) +#if (BL_SPACEDIM == 2) if(argc-1 atoi(clbx) || atoi(clsy) > atoi(clby)) { cout << "A sub-region box must be specified as:\n\t " << " \n" << endl; @@ -796,7 +825,7 @@ void AVGlobals::ParseCommandLine(int argc, char *argv[]) { comlinebox.setSmall(YDIR, atoi(clsy)); comlinebox.setBig(XDIR, atoi(clbx)); comlinebox.setBig(YDIR, atoi(clby)); -# else +#else if(atoi(clsx) > atoi(clbx) || atoi(clsy) > atoi(clby) || atoi(clsz) > atoi(clbz)) { @@ -810,8 +839,16 @@ void AVGlobals::ParseCommandLine(int argc, char *argv[]) { comlinebox.setBig(XDIR, atoi(clbx)); comlinebox.setBig(YDIR, atoi(clby)); comlinebox.setBig(ZDIR, atoi(clbz)); -# endif +#endif + } + +#if (BL_SPACEDIM == 3) + if(givenInitialPlanes) { + ivInitialPlanes.setVal(XDIR, atoi(clPlaneX)); + ivInitialPlanes.setVal(YDIR, atoi(clPlaneY)); + ivInitialPlanes.setVal(ZDIR, atoi(clPlaneZ)); } +#endif if(fileType == INVALIDTYPE) { @@ -852,6 +889,9 @@ int AVGlobals::SleepTime() { return sleepTime; } int AVGlobals::GetMaxLevel() { return maxLevel; } bool AVGlobals::UseMaxLevel() { return useMaxLevel; } +void AVGlobals::SetShowBody(const bool bsb) { bShowBody = bsb; } +bool AVGlobals::GetShowBody() { return bShowBody; } + const string &AVGlobals::GetComlineFilename(int i) { return comlinefilename[i]; } FileType AVGlobals::GetDefaultFileType() { return fileType; } @@ -879,7 +919,7 @@ Array< list > &AVGlobals::GetDumpSlices() { return dumpSliceList; } int AVGlobals::GetFabOutFormat() { return fabIOSize; } bool AVGlobals::UseSpecifiedMinMax() { return specifiedMinMax; } -void AVGlobals::SetSpecifiedMinMax(Real specifiedmin, Real specifiedmax) { +void AVGlobals::SetSpecifiedMinMax(Real specifiedmin, Real specifiedmax) { specifiedMin = specifiedmin; specifiedMax = specifiedmax; } @@ -889,6 +929,8 @@ void AVGlobals::GetSpecifiedMinMax(Real &specifiedmin, Real &specifiedmax) { specifiedmax = specifiedMax; } +bool AVGlobals::GivenInitialPlanes() { return givenInitialPlanes; } +IntVect AVGlobals::GetInitialPlanes() { return ivInitialPlanes; } // ------------------------------------------------------------------- int AVGlobals::CRRBetweenLevels(int fromlevel, int tolevel, diff --git a/ListIterator.H b/ListIterator.H deleted file mode 100644 index c21a9c2..0000000 --- a/ListIterator.H +++ /dev/null @@ -1,638 +0,0 @@ - -#ifndef BL_LIST_H -#define BL_LIST_H - -// -// $Id: ListIterator.H,v 1.2 2001-11-16 01:48:08 vince Exp $ -// - -#include -#include - -#ifdef BL_NAMESPACE -namespace BL_NAMESPACE -{ -#endif - -template class ListLink; -template class ListIterator; -template class List; - -template -class ListLink -{ -private: - friend class List; - friend class ListIterator; - - ListLink (const T& _val, - ListLink* _pre, - ListLink* _suc) - : - val(_val), - pre(_pre), - suc(_suc) {} - -private: - T val; - ListLink* pre; - ListLink* suc; -}; - -template -class ListIterator -{ -public: - explicit ListIterator (const List& aList); - ListIterator (const ListIterator& rhs); - void rewind (); - const T& operator() () const; - const T& operator* () const; - operator void* (); - bool operator! () const; - const T& value () const; - ListIterator& operator++ (); - ListIterator& operator-- (); - ListIterator operator-- (int); - ListIterator operator++ (int); - bool operator== (const ListIterator&) const; - bool operator!= (const ListIterator&) const; - -protected: - ListIterator (const List& _list, ListLink* _p); - const List& list; - ListLink* p; - -private: - friend class List; - ListIterator (); - ListIterator& operator= (const ListIterator&); -}; - -template -class List -{ -public: - List (); - List (const List& rhs); - List& operator= (const List& rhs); - ~List(); - void prepend (const T& value); - void append (const T& value); - void add (const T& value); - void join (const List& src); - void catenate (List& src); - void clear (); - T& firstElement () const; - T& lastElement () const; - bool includes (const T& value) const; - bool operator== (const List& rhs) const; - bool operator!= (const List& rhs) const; - bool isEmpty () const; - bool isNotEmpty () const; - int length () const; - void removeFirst (); - void removeLast (); - const T& operator[] (const ListIterator& li) const; - T& operator[] (const ListIterator& li); - void remove (const T& value); - void remove (const List& lst); - void remove (ListIterator& lit); - void replace (ListIterator& li, const T& val); - void addAfter (ListIterator& lit, const T& val); - void addBefore (ListIterator& lit, const T& val); - ListIterator first () const; - ListIterator last () const; - -protected: - void remove (ListLink *ln); - ListLink* addBefore (ListLink* ln, const T& val); - ListLink* addAfter (ListLink* ln, const T& val); - ListLink* head; - ListLink* tail; - friend class ListIterator; -}; - -template -inline -ListIterator::ListIterator (const List& _list, - ListLink* _p) - : - list(_list), - p(_p) -{} - -template -inline -ListIterator::ListIterator (const List& aList) - : - list(aList) -{ - p = list.head; -} - -template -inline -ListIterator::ListIterator (const ListIterator& li) - : - list(li.list), - p(li.p) -{} - -template -inline -void -ListIterator::rewind () -{ - p = list.head; -} - -template -inline -const T& -ListIterator::operator() () const -{ - BL_ASSERT(p != 0); - return p->val; -} - -template -inline -const T& -ListIterator::operator* () const -{ - BL_ASSERT(p != 0); - return p->val; -} - -template -inline -ListIterator::operator void* () -{ - return p != 0 ? this : 0; -} - -template -inline -bool -ListIterator::operator! () const -{ - return p == 0 ? true : false; -} - -template -inline -const T& -ListIterator::value () const -{ - BL_ASSERT(p != 0); - return p->val; -} - -template -inline -ListIterator& -ListIterator::operator++ () -{ - if (p) - p = p->suc; - return *this; -} - -template -inline -ListIterator& -ListIterator::operator-- () -{ - if (p) - p = p->pre; - return *this; -} - -template -inline -ListIterator -ListIterator::operator++ (int) -{ - const ListIterator li = *this; - ++(*this); - return li; -} - -template -inline -ListIterator -ListIterator::operator-- (int) -{ - const ListIterator li = *this; - --(*this); - return li; -} - -template -inline -bool -ListIterator::operator== (const ListIterator& _li) const -{ - return (&list == &_li.list && p == _li.p) ? true : false; -} - -template -inline -bool -ListIterator::operator!= (const ListIterator& _li) const -{ - return ! ListIterator::operator==(_li); -} - -template -inline -List::List () - : - head(0), - tail(0) -{} - -template -inline -List::~List () -{ - clear(); -} - -template -inline -void -List::prepend (const T& value) -{ - addBefore(head, value); -} - -template -inline -void -List::append (const T& value) -{ - addAfter(tail, value); -} - -template -inline -T& -List::firstElement () const -{ - BL_ASSERT(head != 0); - return head->val; -} - -template -inline -T& -List::lastElement () const -{ - BL_ASSERT(tail != 0); - return tail->val; -} - -template -inline -bool -List::isEmpty () const -{ - return head == 0 && tail == 0; -} - -template -inline -bool -List::isNotEmpty () const -{ - return !isEmpty(); -} - -template -inline -void -List::removeFirst () -{ - remove(head); -} - -template -inline -void -List::removeLast () -{ - remove(tail); -} - -template -inline -const T& -List::operator[] (const ListIterator& li) const -{ - BL_ASSERT(li.p != 0); - return li.p->val; -} - -template -inline -T& -List::operator[] (const ListIterator& li) -{ - BL_ASSERT(li.p != 0); - return li.p->val; -} - -template -inline -void -List::replace (ListIterator& li, - const T& _val) -{ - BL_ASSERT(li.p != 0); - li.p->val = _val; -} - -template -inline -void -List::addAfter (ListIterator& lit, - const T& val) -{ - addAfter(lit.p, val); -} - -template -inline -void -List::addBefore (ListIterator& lit, - const T& val) -{ - addBefore(lit.p, val); -} - -template -inline -ListIterator -List::first () const -{ - return ListIterator(*this,head); -} - -template -inline -ListIterator -List::last () const -{ - return ListIterator(*this,tail); -} - -template -List::List (const List& source) - : - head(0), - tail(0) -{ - if (source.isEmpty()) - tail = head = 0; - else - for (ListIterator li(source); li; ++li) - append(li()); -} - - -template -void -List::add (const T& value) -{ - append(value); -} - -template -int -List::length () const -{ - int len = 0; - for (ListIterator li(*this); li; ++li) - len++; - return len; -} - -template -List& -List::operator= (const List& source) -{ - if (!(this == &source)) - { - clear(); - for (ListIterator li(source); li; ++li) - append(li()); - } - return *this; -} - -template -ListLink * -List::addBefore (ListLink* ln, - const T& val) -{ - BL_ASSERT(ln != 0 || head == 0); - - ListLink* newlink; - - if (ln == head) - { - head = newlink = new ListLink(val, 0, head); - - if (tail == 0) - tail = head; - else - head->suc->pre = newlink; - } - else - { - newlink = new ListLink(val, ln->pre, ln); - - ln->pre->suc = newlink; - ln->pre = newlink; - } - - return newlink; -} - -template -ListLink* -List::addAfter (ListLink* ln, - const T& val) -{ - BL_ASSERT(ln != 0 || tail == 0); - - ListLink* newlink; - - if (ln == tail) - { - tail = newlink = new ListLink(val,tail,0); - - if (head == 0) - head = tail; - else - tail->pre->suc = newlink; - } - else - { - newlink = new ListLink(val, ln, ln->suc); - - ln->suc->pre = newlink; - ln->suc = newlink; - } - - return newlink; -} - -template -void -List::join (const List& list2) -{ - for (ListIterator li2(list2); li2; ++li2) - append(li2()); -} - -template -void -List::catenate (List& list2) -{ - if (list2.isEmpty()) - // - // Do nothing. - // - ; - else if (isEmpty()) - { - head = list2.head; - tail = list2.tail; - list2.head = 0; - list2.tail = 0; - } - else - { - tail->suc = list2.head; - list2.head->pre = tail; - tail = list2.tail; - list2.head = 0; - list2.tail = 0; - } -} - -template -void -List::clear () -{ - ListLink* next = 0; - - for (ListLink* p = head; p != 0; p = next) - { - next = p->suc; - p->suc = 0; - delete p; - } - tail = head = 0; -} - -template -bool -List::includes (const T& v) const -{ - bool rc = false; - for (ListIterator li(*this); li && !rc; ++li) - if (v == li()) - rc = true; - return rc; -} - -template -bool -List::operator== (const List& rhs) const -{ - if (length() == rhs.length()) - { - for (ListIterator li(*this), ri(rhs); li; ++li, ++ri) - if (li() != ri()) - return false; - return true; - } - - return false; -} - -template -bool -List::operator!= (const List& rhs) const -{ - return !operator==(rhs); -} - -template -void -List::remove (ListIterator& li) -{ - ListLink *np = li.p->suc; - remove(li.p); - li.p = np; -} - -template -void -List::remove (const T& _v) -{ - for (ListIterator litr(*this); litr; ++litr) - if (litr() == _v) - remove(litr); -} - -template -void -List::remove (const List& _lv) -{ - for (ListIterator litr(_lv); litr; ++litr) - remove(litr()); -} - -template -void -List::remove (ListLink* ln) -{ - BL_ASSERT(head !=0 && tail != 0); - - if (head == ln && tail == ln) - head = tail = 0; - else if (head == ln) - { - BL_ASSERT(ln->pre == 0); - head = ln->suc; - head->pre = 0; - } - else if (tail == ln) - { - BL_ASSERT(ln->suc == 0); - tail = ln->pre; - tail->suc = 0; - } - else - { - BL_ASSERT(ln->suc != 0 && ln->pre != 0); - ln->suc->pre = ln->pre; - ln->pre->suc = ln->suc; - } - delete ln; - ln = 0; -} - -#ifdef BL_NAMESPACE -} -#ifndef BL_NO_USING_DIRECTIVE -using namespace BL_NAMESPACE; -#endif -#endif - -#endif /*BL_LIST_H*/ diff --git a/PltApp.H b/PltApp.H index d71531a..43934b2 100644 --- a/PltApp.H +++ b/PltApp.H @@ -1,6 +1,6 @@ // -// $Id: PltApp.H,v 1.62 2002-12-10 20:12:23 vince Exp $ +// $Id: PltApp.H,v 1.63 2004-04-16 23:50:43 vince Exp $ // // --------------------------------------------------------------- @@ -88,6 +88,7 @@ public: static void SetDefaultLightingFile(const string &lightFileString); static void SetInitialDerived(const string &initialderived); static void SetInitialScale(int initScale); + static void SetInitialMaxMenuItems(int initmaxitems); static int GetInitialScale(); static void SetInitialFormatString(const string &formatString); static void SetDefaultShowBoxes(int showBoxes); @@ -209,7 +210,7 @@ private: PltAppState *pltAppState; Display *display; GC xgc; - bool bFileRangeButtonSet; + bool bFileRangeButtonSet, bSyncFrame; void DoToggleFileRangeButton(Widget, XtPointer, XtPointer); // baggage for fast rubber banding @@ -220,6 +221,7 @@ private: static string defaultPaletteString, initialDerived, initialFormatString; static string defaultLightingFilename; + static int initialMaxMenuItems; static int initialScale, initialWindowHeight, initialWindowWidth; static int defaultShowBoxes, placementOffsetX, placementOffsetY; static int reserveSystemColors; @@ -378,6 +380,7 @@ void SubregionPltApp(Widget toplevel, const Box ®ion, const IntVect &offset, int isanim, const string &derived, const string &filename); void CBQuitPltApp(Widget, XtPointer, XtPointer); +void CBQuitAll(Widget, XtPointer, XtPointer); void PrintMessage(char *cpmsg); #endif diff --git a/PltApp.cpp b/PltApp.cpp index 47e9228..fd52d0a 100644 --- a/PltApp.cpp +++ b/PltApp.cpp @@ -1,6 +1,6 @@ // -// $Id: PltApp.cpp,v 1.121 2003-12-18 23:32:53 vince Exp $ +// $Id: PltApp.cpp,v 1.122 2004-04-16 23:50:43 vince Exp $ // // --------------------------------------------------------------- @@ -203,7 +203,6 @@ PltApp::PltApp(XtAppContext app, Widget w, const string &filename, pltAppState->SetCurrentScale(currentScale); pltAppState->SetMaxScale(maxAllowableScale); -// --------------- pltAppState->SetMinMaxRangeType(GLOBALMINMAX); Real rGlobalMin, rGlobalMax; rGlobalMin = AV_BIG_REAL; @@ -260,7 +259,6 @@ PltApp::PltApp(XtAppContext app, Widget w, const string &filename, specifiedMin, specifiedMax); } } -// --------------- amrPicturePtrArray[ZPLANE] = new AmrPicture(gaPtr, this, pltAppState, @@ -435,7 +433,7 @@ PltApp::PltApp(XtAppContext app, Widget w, const Box ®ion, } #if (BL_SPACEDIM == 3) - for(int i(0); i < 3; ++i) { + for(int i(0); i < BL_SPACEDIM; ++i) { amrPicturePtrArray[i]->SetHVLine(pltAppState->CurrentScale()); } #endif @@ -461,12 +459,13 @@ void PltApp::PltAppInit(bool bSubVolume) { for(np = 0; np != BL_SPACEDIM; ++np) { XYplotwin[np] = NULL; // No 1D plot windows initially. - // For speed (and clarity!) we store the values of the finest value of h of + // For speed (and clarity) we store the values of the finest value of h of // each dimension, as well as the low value of the problem domain in simple // arrays. These are both in problem space. finestDx[np] = amrData.DxLevel()[maxAllowableLevel][np]; gridOffset[np] = amrData.ProbLo()[np]; } + bSyncFrame = false; placementOffsetX += 20; placementOffsetY += 20; @@ -495,7 +494,7 @@ void PltApp::PltAppInit(bool bSubVolume) { amrPicturePtrArray[np]->SetRegion(startX, startY, endX, endY); } - char tempFormat[32]; + char tempFormat[128]; strcpy(tempFormat, PltApp::initialFormatString.c_str()); XmString sFormatString = XmStringCreateSimple(tempFormat); char *tempchar = new char[LINELENGTH]; @@ -582,6 +581,18 @@ void PltApp::PltAppInit(bool bSubVolume) { wCascade, XmNmnemonic, 'F', NULL); AddStaticCallback(wid, XmNactivateCallback, &PltApp::DoOutput, (XtPointer) 2); + // Quit + XtVaCreateManagedWidget(NULL, xmSeparatorGadgetClass, wMenuPulldown, NULL); + label_str = XmStringCreateSimple("Ctrl+Q"); + wid = XtVaCreateManagedWidget("Quit", xmPushButtonGadgetClass, wMenuPulldown, + XmNmnemonic, 'Q', + XmNaccelerator, "CtrlQ", + XmNacceleratorText, label_str, + NULL); + XmStringFree(label_str); + XtAddCallback(wid, XmNactivateCallback, (XtCallbackProc) CBQuitAll, + (XtPointer) this); + // Close XtVaCreateManagedWidget(NULL, xmSeparatorGadgetClass, wMenuPulldown, NULL); label_str = XmStringCreateSimple("Ctrl+C"); @@ -732,7 +743,7 @@ void PltApp::PltAppInit(bool bSubVolume) { AddStaticCallback(wid, XmNvalueChangedCallback, &PltApp::DoBoxesButton); // ------------------------------- derived menu - int maxMenuItems(20); // arbitrarily + int maxMenuItems(initialMaxMenuItems); // arbitrarily int numberOfDerived(dataServicesPtr[currentFrame]->NumDeriveFunc()); const Array &derivedStrings = dataServicesPtr[currentFrame]->PlotVarNames(); @@ -744,7 +755,6 @@ void PltApp::PltAppInit(bool bSubVolume) { ((numberOfDerived % maxMenuItems == 0) ? 0 : 1), NULL); XtVaCreateManagedWidget("Variable", xmCascadeButtonWidgetClass, wMenuBar, XmNmnemonic, 'a', XmNsubMenuId, wMenuPulldown, NULL); - //unsigned long cderived(0); wCurrDerived = XtVaCreateManagedWidget(derivedStrings[0].c_str(), xmToggleButtonGadgetClass, wMenuPulldown, XmNset, true, NULL); @@ -758,7 +768,6 @@ void PltApp::PltAppInit(bool bSubVolume) { XtVaSetValues(wCurrDerived, XmNset, false, NULL); XtVaSetValues(wid, XmNset, true, NULL); wCurrDerived = wid; - //cderived = derived; } AddStaticCallback(wid, XmNvalueChangedCallback, &PltApp::ChangeDerived, (XtPointer) derived); @@ -956,7 +965,6 @@ void PltApp::PltAppInit(bool bSubVolume) { XmNx, centerX-halfbutton, XmCMarginBottom, 2, NULL); - //XtManageChild(wControls[WCASTOP]); wControls[WCATNEG] = XtVaCreateManagedWidget("wcatneg", xmArrowButtonWidgetClass, wControlForm, @@ -1001,7 +1009,6 @@ void PltApp::PltAppInit(bool bSubVolume) { } AddStaticCallback(wControls[WCARGB], XmNactivateCallback, &PltApp::ChangePlane, (XtPointer) WCARGB); - //XtManageChild(wControls[WCARGB]); wWhichFileScale = XtVaCreateManagedWidget("whichFileScale", xmScaleWidgetClass, wControlForm, @@ -1653,7 +1660,8 @@ void PltApp::ChangeDerived(Widget w, XtPointer client_data, XtPointer) { } if(AVGlobals::Verbose()) { cout << "_in PltApp::ChangeDerived" << endl; - pltAppState->PrintSetMap(); cout << endl; + pltAppState->PrintSetMap(); + cout << endl; } @@ -2507,9 +2515,6 @@ void PltApp::DoSetRangeButton(Widget, XtPointer, XtPointer) { int isrw, iwidw, itotalwidth, maxwidth(600); XtVaGetValues(wSetRangeRadioBox, XmNwidth, &isrw, NULL); XtVaGetValues(wid, XmNwidth, &iwidw, NULL); - //cout << "============ _here 00:" << endl; - //cout << "iw.. = " << isrw + (2 * iwidw) + 10 << endl; - //cout << "isrw = " << isrw << " iwidw = " << iwidw << endl; itotalwidth = min(isrw + (2 * iwidw) + 10, maxwidth); XtVaSetValues(wSetRangeTopLevel, XmNwidth, itotalwidth, NULL); } @@ -2969,8 +2974,9 @@ XYPlotDataList *PltApp::CreateLinePlot(int V, int sdir, int mal, int ix, gridOffset[dir2]); #endif } - XYPlotDataList *newlist = new XYPlotDataList(*derived, mal, ix, - amrData.RefRatio(), + XYPlotDataList *newlist = new XYPlotDataList(*derived, + pltAppState->MinDrawnLevel(), mal, + ix, amrData.RefRatio(), XdX, intersectStr, gridOffset[sdir]); bool lineOK; DataServices::Dispatch(DataServices::LineValuesRequest, @@ -3012,6 +3018,8 @@ void PltApp::DoRubberBanding(Widget, XtPointer client_data, XtPointer call_data) int rootX, rootY; unsigned int inputMask; Window whichRoot, whichChild; + bool bShiftDown(cbs->event->xbutton.state & ShiftMask); + bool bControlDown(cbs->event->xbutton.state & ControlMask); #if (BL_SPACEDIM == 3) int x1, y1, z1, x2, y2, z2, rStartPlane; for(int np = 0; np != BL_SPACEDIM; ++np) { @@ -3024,13 +3032,19 @@ void PltApp::DoRubberBanding(Widget, XtPointer client_data, XtPointer call_data) ResetAnimation(); } - XSetForeground(display, rbgc, 120); + XSetForeground(display, rbgc, pltPaletteptr->makePixel(120)); XChangeActivePointerGrab(display, PointerMotionHintMask | ButtonMotionMask | ButtonReleaseMask | OwnerGrabButtonMask, cursor, CurrentTime); AVXGrab avxGrab(display); if(servingButton == 1) { + if(bShiftDown) { + oldX = 0; + } + if(bControlDown) { + oldY = 0; + } int rectDrawn(false); int anchorX(oldX); int anchorY(oldY); @@ -3095,6 +3109,12 @@ void PltApp::DoRubberBanding(Widget, XtPointer client_data, XtPointer call_data) &whichRoot, &whichChild, &rootX, &rootY, &newX, &newY, &inputMask); + if(bShiftDown) { + newX = imageWidth; + } + if(bControlDown) { + newY = imageHeight; + } newX = max(0, min(imageWidth, newX)); newY = max(0, min(imageHeight, newY)); rWidth = abs(newX-anchorX); // draw the new rectangle @@ -3193,6 +3213,15 @@ void PltApp::DoRubberBanding(Widget, XtPointer client_data, XtPointer call_data) startY = (max(0, min(imageHeight, anchorY))) / scale; endX = (max(0, min(imageWidth, nextEvent.xbutton.x))) / scale; endY = (max(0, min(imageHeight, nextEvent.xbutton.y))) / scale; + + if(bShiftDown) { + startX = 0; + endX = imageWidth / scale; + } + if(bControlDown) { + startY = 0; + endY = imageHeight / scale; + } // make "aligned" box with correct size, converted to AMR space. selectionBox.setSmall(XDIR, min(startX, endX)); @@ -3268,7 +3297,10 @@ void PltApp::DoRubberBanding(Widget, XtPointer client_data, XtPointer call_data) string dataValueString(dataValueCharString); const string vfDerived("vfrac"); - if(amrData.CartGrid() && pltAppState->CurrentDerived() != vfDerived) { + bool bShowBody(AVGlobals::GetShowBody()); + if(amrData.CartGrid() && pltAppState->CurrentDerived() != vfDerived && + bShowBody) + { DataServices::Dispatch(DataServices::PointValueRequest, dataServicesPtr[currentFrame], trueRegion.size(), @@ -3282,6 +3314,10 @@ void PltApp::DoRubberBanding(Widget, XtPointer client_data, XtPointer call_data) dataValueString = "body"; } } + bool bIsMF(dataServicesPtr[currentFrame]->GetFileType() == MULTIFAB); + if(bIsMF && intersectedLevel == 0) { + dataValueString = "no data"; + } ostrstream buffout(buffer, BUFSIZ); if(goodIntersect) { @@ -3325,6 +3361,7 @@ void PltApp::DoRubberBanding(Widget, XtPointer client_data, XtPointer call_data) startY = imageHeight - selectionBox.smallEnd(YDIR) * scale; endY = imageHeight - selectionBox.bigEnd(YDIR) * scale; } + int nodeAdjustment = (scale - 1) * selectionBox.type()[YDIR]; startY -= nodeAdjustment; endY -= nodeAdjustment; @@ -3705,6 +3742,7 @@ void PltApp::DoExposePalette(Widget, XtPointer, XtPointer) { // ------------------------------------------------------------------- void PltApp::PADoExposePicture(Widget w, XtPointer client_data, XtPointer) { unsigned long np = (unsigned long) client_data; +//cout << "==%%%%%%%%%%%%=== _in PADoExposePicture: currentFrame = " << currentFrame << endl; amrPicturePtrArray[np]->DoExposePicture(); // draw bounding box @@ -3938,39 +3976,42 @@ void PltApp::ChangePlane(Widget, XtPointer data, XtPointer cbs) { if(which == WCASTOP) { writingRGB = false; + bSyncFrame = true; + pltAppState->SetCurrentFrame(currentFrame); StopAnimation(); return; } XmPushButtonCallbackStruct *cbstr = (XmPushButtonCallbackStruct *) cbs; - if(cbstr->click_count > 1) { + bool bShiftDown(cbstr->event->xbutton.state & ShiftMask); + if(cbstr->click_count > 1 || bShiftDown) { switch(which) { #if (BL_SPACEDIM == 3) - case WCXNEG: amrPicturePtrArray[XPLANE]->Sweep(ANIMNEGDIR); return; - case WCXPOS: amrPicturePtrArray[XPLANE]->Sweep(ANIMPOSDIR); return; - case WCYNEG: amrPicturePtrArray[YPLANE]->Sweep(ANIMNEGDIR); return; - case WCYPOS: amrPicturePtrArray[YPLANE]->Sweep(ANIMPOSDIR); return; - case WCZNEG: amrPicturePtrArray[ZPLANE]->Sweep(ANIMNEGDIR); return; - case WCZPOS: amrPicturePtrArray[ZPLANE]->Sweep(ANIMPOSDIR); return; + case WCXNEG: amrPicturePtrArray[XPLANE]->Sweep(ANIMNEGDIR); return; + case WCXPOS: amrPicturePtrArray[XPLANE]->Sweep(ANIMPOSDIR); return; + case WCYNEG: amrPicturePtrArray[YPLANE]->Sweep(ANIMNEGDIR); return; + case WCYPOS: amrPicturePtrArray[YPLANE]->Sweep(ANIMPOSDIR); return; + case WCZNEG: amrPicturePtrArray[ZPLANE]->Sweep(ANIMNEGDIR); return; + case WCZPOS: amrPicturePtrArray[ZPLANE]->Sweep(ANIMPOSDIR); return; #endif - case WCATNEG: Animate(ANIMNEGDIR); return; - case WCATPOS: Animate(ANIMPOSDIR); return; - case WCARGB: writingRGB = true; Animate(ANIMPOSDIR); return; - default: return; + case WCATNEG: Animate(ANIMNEGDIR); return; + case WCATPOS: Animate(ANIMPOSDIR); return; + case WCARGB: writingRGB = true; Animate(ANIMPOSDIR); return; + default: return; } } - switch (which) { + switch(which) { #if (BL_SPACEDIM == 3) - case WCXNEG: DoBackStep(XPLANE); return; - case WCXPOS: DoForwardStep(XPLANE); return; - case WCYNEG: DoBackStep(YPLANE); return; - case WCYPOS: DoForwardStep(YPLANE); return; - case WCZNEG: DoBackStep(ZPLANE); return; - case WCZPOS: DoForwardStep(ZPLANE); return; + case WCXNEG: DoBackStep(XPLANE); return; + case WCXPOS: DoForwardStep(XPLANE); return; + case WCYNEG: DoBackStep(YPLANE); return; + case WCYPOS: DoForwardStep(YPLANE); return; + case WCZNEG: DoBackStep(ZPLANE); return; + case WCZPOS: DoForwardStep(ZPLANE); return; #endif - case WCATNEG: DoAnimBackStep(); return; - case WCATPOS: DoAnimForwardStep(); return; - case WCARGB: writingRGB = true; DoAnimForwardStep(); return; + case WCATNEG: DoAnimBackStep(); return; + case WCATPOS: DoAnimForwardStep(); return; + case WCARGB: writingRGB = true; DoAnimForwardStep(); return; } } @@ -4015,7 +4056,7 @@ void PltApp::DoAnimFileScale(Widget, XtPointer, XtPointer cbs) { void PltApp::ResetAnimation() { StopAnimation(); if( ! interfaceReady) { -# if(BL_SPACEDIM == 2) +#if(BL_SPACEDIM == 2) int maLev(pltAppState->MaxAllowableLevel()); AmrPicture *Tempap = amrPicturePtrArray[ZPLANE]; XtRemoveEventHandler(wPlotPlane[ZPLANE], ExposureMask, false, @@ -4043,7 +4084,7 @@ void PltApp::ResetAnimation() { AddStaticEventHandler(wPlotPlane[ZPLANE], ExposureMask, &PltApp::PADoExposePicture, (XtPointer) ZPLANE); interfaceReady = true; -# endif +#endif } } @@ -4118,10 +4159,10 @@ void PltApp::DoUpdateFrame(Widget, XtPointer, XtPointer) { void PltApp::ShowFrame() { interfaceReady = false; const AmrData &amrData = dataServicesPtr[currentFrame]->AmrDataRef(); - if( ! readyFrames[currentFrame] || datasetShowing || + if( ! readyFrames[currentFrame] || datasetShowing || bSyncFrame || UsingFileRange(currentRangeType)) { -# if(BL_SPACEDIM == 2) +#if (BL_SPACEDIM == 2) AmrPicture *tempapSF = amrPicturePtrArray[ZPLANE]; Array domain = amrPicturePtrArray[ZPLANE]->GetSubDomain(); XtRemoveEventHandler(wPlotPlane[ZPLANE], ExposureMask, false, @@ -4144,9 +4185,10 @@ void PltApp::ShowFrame() { AddStaticEventHandler(wPlotPlane[ZPLANE], ExposureMask, &PltApp::PADoExposePicture, (XtPointer) ZPLANE); frameBuffer[currentFrame] = amrPicturePtrArray[ZPLANE]->GetPictureXImage(); -# endif +#endif readyFrames[currentFrame] = true; paletteDrawn = ! UsingFileRange(currentRangeType); + bSyncFrame = false; } XPutImage(display, XtWindow(wPlotPlane[ZPLANE]), xgc, @@ -4260,6 +4302,7 @@ void PltApp::StaticTimeOut(XtPointer client_data, XtIntervalId * call_data) { // ------------------------------------------------------------------- int PltApp::initialScale; +int PltApp::initialMaxMenuItems = 20; int PltApp::defaultShowBoxes; int PltApp::initialWindowHeight; int PltApp::initialWindowWidth; @@ -4289,6 +4332,10 @@ void PltApp::SetInitialDerived(const string &initialderived) { PltApp::initialDerived = initialderived; } +void PltApp::SetInitialMaxMenuItems(int initMaxMenuItems) { + PltApp::initialMaxMenuItems = initMaxMenuItems; +} + void PltApp::SetInitialScale(int initScale) { PltApp::initialScale = initScale; } diff --git a/XYPlotDataList.H b/XYPlotDataList.H index 5f53238..e7699c6 100644 --- a/XYPlotDataList.H +++ b/XYPlotDataList.H @@ -4,100 +4,118 @@ #ifndef XYPLOTDATALIST_H #define XYPLOTDATALIST_H -#include #include #include #include -#include #include +#include #include using std::string; +using std::list; -class XYPlotDataListLink { - friend class XYPlotDataListIterator; - friend class XYPlotDataList; - +class OrderedBoxes { public: + OrderedBoxes(const int level, int idir, const Box &databox, const Box &finebox) + : iLevel(level), iDir(idir), dataBox(databox), finestBox(finebox) + { } + + int ILevel() const { return iLevel; } + const Box &DataBox() const { return dataBox; } + const Box &FinestBox() const { return finestBox; } + bool operator<(const OrderedBoxes &ob) const { + return(finestBox.smallEnd()[iDir] < ob.finestBox.smallEnd()[iDir]); + } + + protected: + int iLevel, iDir; + Box dataBox, finestBox; + +}; + - XYPlotDataListLink(Real *d, int sX, int len) - : data(d), length(len), startXi(sX) +class XYPlotDataListLink { + public: + XYPlotDataListLink(const Real *d, int sX, int len) + : xypdllLength(len), startXi(sX) { BL_ASSERT(len != 0); - }; + endXi = sX + len; + xypdllData = new Real[len]; + for(int i(0); i < len; ++i) { + xypdllData[i] = d[i]; + } + } + + ~XYPlotDataListLink() { + delete [] xypdllData; + } + + Real *XYPDLLData() const { return xypdllData; } + int XYDPLLength() const { return xypdllLength; } + int StartXi() const { return startXi; } + int EndXi() const { return endXi; } + bool operator<(const XYPlotDataListLink &xyp) const { + return(startXi < xyp.startXi); + } protected: - Real *data; - int length, startXi, endXi; - XYPlotDataListLink *down; - int nDown; + Real *xypdllData; + int xypdllLength, startXi, endXi; }; class XYPlotDataList { - friend class XYPlotWin; - friend class XYPlotDataListLink; - friend class XYPlotDataListIterator; - public: - XYPlotDataList(const string &_derived, int max_level, - int _gridline, - const Array &ratio_list, - const Array &d_x, - const Array &intersect_point, - Real start_x = 0.0); + XYPlotDataList(const string &derived, int minlevel, int maxlevel, + int gridlinein, + const Array &ratiolist, + const Array &dx, + const Array &intersectpoint, + Real startx = 0.0); XYPlotDataList(XYPlotDataList *src); - ~XYPlotDataList(); - char IsEmpty(void) { return emptyQ; } void AddFArrayBox(FArrayBox &fab, int direction, int level); void UpdateStats(void); void SetLevel(int new_level) { curLevel = (new_level < maxLevel) ? new_level : maxLevel; } + const string &DerivedName() const { return xypdlDerived; } + const XYPlotDataList *CopiedFrom() const { return copiedFrom; } + void SetCopiedFrom(XYPlotDataList *xypdl) { copiedFrom = xypdl; } + int MaxLevel() const { return maxLevel; } + int NumPoints() const { return numPoints[curLevel]; } + int CurLevel() const { return curLevel; } + int Gridline() const { return gridline; } + double StartX() const { return startX; } + double EndX() const { return endX; } + double XYPDLLoY(const int ilev) const { return xypdlLoY[ilev]; } + double XYPDLHiY(const int ilev) const { return xypdlHiY[ilev]; } + char *IntersectPoint(const int ilev) const { return intersectPoint[ilev]; } + Array &XVal(int level) { return xypdlXVal[level]; } + Array &YVal(int level) { return xypdlYVal[level]; } protected: - Array *> dataSets; - Array *> upXi; // Used for data set iteration [level] - Array ratios; // Used for insertion of data sets beginning + Array > dataSets; + Array xypdlRatios; // Used for insertion of data sets beginning // in the middle of a single cell [level] - Array dX; // dX in the proper direction [level] - Array intersectPoint; // Intersected value (in problem space) + Array dX; // dX in the proper direction [level] + Array intersectPoint; // Intersected value (in problem space) // for labelling plots [level] - Array lloY; // min Y [level] - Array hhiY; // max Y [level] + Array xypdlLoY, xypdlHiY; // [level] + Array > xypdlXVal, xypdlYVal; // [level][data] - int numPoints, maxLevel, curLevel, gridline; - char updatedQ, emptyQ; + Array numPoints; + int minLevel, maxLevel, curLevel, gridline, whichDir; + bool updatedQ; double startX, endX, offsetX; - string derived; - XYPlotDataList *copied_from; - - private: - void addLink(XYPlotDataListLink *l, int level); + string xypdlDerived; + XYPlotDataList *copiedFrom; + Array fabBoxLists, fillBoxLists; }; - - -class XYPlotDataListIterator { - public: - explicit XYPlotDataListIterator (XYPlotDataList *aList); - ~XYPlotDataListIterator(); - XYPlotDataListIterator& operator++ (); - bool operator! () const { return (curLink == NULL) ? true : false; } - operator void* () { return (curLink != NULL) ? this : NULL; } - - double xval, yval; - - private: - XYPlotDataList *list; - Array *> XiLI; - Array *> linkLI; - XYPlotDataListLink *curLink, *nextLink; - int curXi, nextXi, curLevel, maxLevel; - Real *data; -}; - #endif +// ------------------------------------------------------------------- +// ------------------------------------------------------------------- diff --git a/XYPlotDataList.cpp b/XYPlotDataList.cpp index e8cc95c..b54ded7 100644 --- a/XYPlotDataList.cpp +++ b/XYPlotDataList.cpp @@ -2,351 +2,226 @@ // XYPlotDataList.cpp // ------------------------------------------------------------------- #include "XYPlotDataList.H" +#include "GlobalUtilities.H" #include -#define STRDUP(xx) (strcpy(new char[strlen(xx)+1], (xx))) - // ------------------------------------------------------------------- -XYPlotDataList::XYPlotDataList(const string &_derived, int max_level, - int _gridline, - const Array &ratio_list, - const Array &d_X, - const Array &intersect_point, - Real offset_x) - : dataSets(max_level+1), - upXi(max_level), - ratios(ratio_list), - dX(d_X), - intersectPoint(intersect_point), - lloY(max_level+1), - hhiY(max_level+1), - maxLevel(max_level), - gridline(_gridline), - offsetX(offset_x), - derived(_derived) +XYPlotDataList::XYPlotDataList(const string &derived, int minlevel, + int maxlevel, int gridlinein, + const Array &ratiolist, + const Array &dx, + const Array &intersectpoint, + Real offsetx) + : dataSets(maxlevel + 1), + xypdlRatios(ratiolist), + dX(dx), + intersectPoint(intersectpoint), + xypdlLoY(maxlevel + 1), + xypdlHiY(maxlevel + 1), + xypdlXVal(maxlevel + 1), + xypdlYVal(maxlevel + 1), + numPoints(maxlevel + 1), + minLevel(minlevel), + maxLevel(maxlevel), + gridline(gridlinein), + offsetX(offsetx), + xypdlDerived(derived), + fabBoxLists(maxlevel + 1), + fillBoxLists(maxlevel + 1) { - //cout << "_here 000: max_level = " << max_level << endl; - int idx; - - emptyQ = 1; - updatedQ = 0; + updatedQ = false; curLevel = 0; - copied_from = NULL; - - idx = 0; - while(true) { - //cout << "_here 000.1: making a new dataSet: idx maxLevel = " - // << idx << " " << maxLevel << endl; - dataSets[idx] = new List< XYPlotDataListLink *>(); - if(idx == maxLevel) { - break; - } - upXi[idx] = new List(); - ++idx; - } + copiedFrom = NULL; } // ------------------------------------------------------------------- XYPlotDataList::XYPlotDataList(XYPlotDataList *src) : dataSets(src->dataSets), - upXi(src->upXi), - ratios(src->ratios), + xypdlRatios(src->xypdlRatios), dX(src->dX), intersectPoint(src->intersectPoint), - lloY(src->lloY), - hhiY(src->hhiY), + xypdlLoY(src->xypdlLoY), + xypdlHiY(src->xypdlHiY), numPoints(src->numPoints), maxLevel(src->maxLevel), curLevel(src->curLevel), gridline(src->gridline), updatedQ(src->updatedQ), - emptyQ(src->updatedQ), startX(src->startX), endX(src->endX), offsetX(src->offsetX), - derived(src->derived) + xypdlDerived(src->xypdlDerived) { - //cout << "_here 001" << endl; - if(src->copied_from) { - copied_from = src->copied_from; + if(src->copiedFrom) { + copiedFrom = src->copiedFrom; } else { - copied_from = src; + copiedFrom = src; } } // ------------------------------------------------------------------- XYPlotDataList::~XYPlotDataList() { - if(copied_from == NULL) { - int idx; - for(idx = 0; idx <= maxLevel; ++idx) { - for(ListIterator li(*dataSets[idx]); li; ++li) { - delete (*li)->data; - delete *li; + if(copiedFrom == NULL) { + for(int ilev(0); ilev <= maxLevel; ++ilev) { + delete intersectPoint[ilev]; + for(list::iterator li = dataSets[ilev].begin(); + li != dataSets[ilev].end(); ++li) + { + delete (*li); } - delete dataSets[idx]; - delete intersectPoint[idx]; } - for(idx = 0; idx != maxLevel; ++idx) { - delete upXi[idx]; - } - } -} - - -// ------------------------------------------------------------------- -void XYPlotDataList::AddFArrayBox(FArrayBox &fab, int which_dir, int level) { - int length = fab.length()[which_dir]; - int startXi = fab.smallEnd()[which_dir]; - Real *data = new Real[length]; - Real *FABdata = fab.dataPtr(); - for(int ii(0); ii != length; ++ii) { - data[ii] = FABdata[ii]; } - addLink(new XYPlotDataListLink(data, startXi, length), level); } // ------------------------------------------------------------------- -void XYPlotDataList::addLink(XYPlotDataListLink *linky, int level) { - //cout << "_here 002: level = " << level << endl; +void XYPlotDataList::AddFArrayBox(FArrayBox &fab, int whichdir, int level) { + BL_ASSERT(level >= 0); BL_ASSERT(level <= maxLevel); - emptyQ = 0; - updatedQ = 0; - linky->endXi = linky->startXi + linky->length; - - ListIterator curLevLI(*dataSets[level]); - if(level == 0) { - linky->down = NULL; - - while(true) { - if( ! curLevLI) { - dataSets[0]->append(linky); - break; - } - if((*curLevLI)->startXi > linky->startXi) { - dataSets[0]->addBefore(curLevLI, linky); - break; + whichDir = whichdir; + fabBoxLists[level].push_back(fab.box()); + updatedQ = false; + int istartx(fab.smallEnd()[whichdir]); + XYPlotDataListLink *pdll = new XYPlotDataListLink(fab.dataPtr(), istartx, + fab.length()[whichdir]); + list::iterator li = dataSets[level].begin(); + if(li == dataSets[level].end()) { + dataSets[level].push_back(pdll); + } else { + while((*li)->StartXi() < istartx && li != dataSets[level].end()) { + ++li; + if(li == dataSets[level].end()) { + break; } - ++curLevLI; } - //cout << "_here 002.1: returning" << endl; - return; + dataSets[level].insert(li, pdll); } - - int temp; - - // ASSUMPTION: DATA IS CELL CENTERED. If the box we are adding begins - // more than halfway through the cell on the level below, then we will - // consider the cell below to be "visible". - temp = linky->startXi / ratios[level-1] + - (((linky->startXi % ratios[level-1]) * 2 > ratios[level-1]) ? 1 : 0); - - // Insertion into sorted location. - ListIterator XiLI(*upXi[level-1]); - while(true) { - // If we have reached the end of the list, append to the end. - if( ! curLevLI) { - dataSets[level]->append(linky); - upXi[level-1]->append(temp); - break; - } - - // If the current box in the list begins after the box we are adding, - // we have found the position in the list, so stop. - if((*curLevLI)->startXi > linky->startXi) { - dataSets[level]->addBefore(curLevLI, linky); - upXi[level-1]->addBefore(XiLI, temp); - break; - } - - ++curLevLI; - ++XiLI; - } - - temp = linky->endXi / ratios[level-1]; - - linky->nDown = temp + - (((linky->endXi % ratios[level-1]) * 2 > ratios[level-1]) ? 1 : 0); - - ListIterator preLevLI(*dataSets[level-1]); - //cout << "_here 002.2" << endl; - BL_ASSERT(preLevLI); - XYPlotDataListLink *down = *preLevLI; - while(down->endXi < temp && ++preLevLI) { - down = *preLevLI; - } - linky->down = down; } // ------------------------------------------------------------------- -void XYPlotDataList::UpdateStats(void) { - - // Find the number of points, and the extremes for each level. +void XYPlotDataList::UpdateStats() { if(updatedQ) { return; } - numPoints = 0; - BL_ASSERT(dataSets[0]->firstElement()); + BL_ASSERT(dataSets[minLevel].empty() == false); - { - ListIterator li(*dataSets[0]); - int startXi = (*li)->startXi; - int endXi = (*li)->endXi; - while(++li) { - if((*li)->startXi < startXi) { - startXi = (*li)->startXi; - } - if((*li)->endXi > endXi) { - endXi = (*li)->endXi; - } - } - startX = offsetX + dX[0] * startXi; - endX = offsetX + dX[0] * endXi; - } + int ilev, startxi, endxi; + startxi = dataSets[minLevel].front()->StartXi(); + endxi = dataSets[minLevel].back()->EndXi(); + startX = offsetX + dX[minLevel] * (double) startxi; + endX = offsetX + dX[minLevel] * (double) endxi; - lloY[0] = DBL_MAX; - hhiY[0] = -DBL_MAX; +for(int iCurLevel(maxLevel); iCurLevel >= minLevel; --iCurLevel) { - for(int idx(0); idx <= maxLevel; ++idx) { - for(ListIterator li(*dataSets[idx]); li; ++li) { - Real *ptr = (*li)->data; - numPoints += (*li)->length; - for(int idx2((*li)->length); idx2 != 0; --idx2) { - if(*ptr < lloY[idx]) { - lloY[idx] = *ptr; - } - if(*ptr > hhiY[idx]) { - hhiY[idx] = *ptr; - } - ++ptr; + // back out the probDomain + Box probDomain = fabBoxLists[minLevel].minimalBox(); + probDomain.refine(AVGlobals::CRRBetweenLevels(minLevel, iCurLevel, xypdlRatios)); + for(int isd(0); isd < BL_SPACEDIM; ++isd) { + if(isd != whichDir) { // squish the pd + if(fabBoxLists[iCurLevel].size() > 0) { + probDomain.setSmall(isd, (*(fabBoxLists[iCurLevel].begin())).smallEnd(isd)); + probDomain.setBig(isd, (*(fabBoxLists[iCurLevel].begin())).bigEnd(isd)); } } - if(idx != maxLevel) { - lloY[idx+1] = lloY[idx]; - hhiY[idx+1] = hhiY[idx]; - } - } - updatedQ = 1; -} - - -// ------------------------------------------------------------------- -XYPlotDataListIterator::XYPlotDataListIterator (XYPlotDataList *alist) - : list(alist), - XiLI(alist->curLevel), - linkLI(alist->curLevel+1), - maxLevel(alist->curLevel) -{ - curLevel = 0; - - for(int idx = 0; idx <= maxLevel; ++idx) { - linkLI[idx] = new ListIterator (*list->dataSets[idx]); } - for(int idx = 0; idx != maxLevel; ++idx) { - XiLI[idx] = new ListIterator (*list->upXi[idx]); - } + Array unfilledBoxLists(iCurLevel + 1); + unfilledBoxLists[iCurLevel].push_back(probDomain); - if( ! *linkLI[0]) { - curLink = NULL; - return; - } - curLink = **linkLI[0]; - - int temp; - while(true) { - curXi = curLink->startXi; - nextXi = curLink->endXi; - if(curLevel != maxLevel && *XiLI[curLevel] && - ((temp = **XiLI[curLevel]) < nextXi)) + for(ilev = iCurLevel; ilev >= minLevel; --ilev) { + fillBoxLists[ilev].clear(); + fillBoxLists[ilev].join(unfilledBoxLists[ilev]); + fillBoxLists[ilev].intersect(fabBoxLists[ilev]); + BoxList tempUnfilled; + for(BoxList::iterator bli = unfilledBoxLists[ilev].begin(); + bli != unfilledBoxLists[ilev].end(); ++bli) { - nextXi = temp; - nextLink = **linkLI[curLevel+1]; - ++(*XiLI[curLevel]); - ++(*linkLI[curLevel+1]); - } else { - nextLink = NULL; - break; + tempUnfilled.join(BoxLib::complementIn(*bli, fabBoxLists[ilev])); } - - if(curXi < nextXi) { - break; + unfilledBoxLists[ilev].clear(); + unfilledBoxLists[ilev].join(tempUnfilled); + + if(ilev > minLevel) { + unfilledBoxLists[ilev - 1].clear(); + unfilledBoxLists[ilev - 1].join(unfilledBoxLists[ilev]); + unfilledBoxLists[ilev - 1].coarsen(AVGlobals::CRRBetweenLevels(ilev - 1, + ilev, xypdlRatios)); + for(int isd(0); isd < BL_SPACEDIM; ++isd) { + if(isd != whichDir) { // squish the boxlist + if(fabBoxLists[ilev - 1].size() > 0) { + for(BoxList::iterator bli = unfilledBoxLists[ilev - 1].begin(); + bli != unfilledBoxLists[ilev - 1].end(); ++bli) + { + (*bli).setSmall(isd, (*(fabBoxLists[ilev - 1].begin())).smallEnd(isd)); + (*bli).setBig(isd, (*(fabBoxLists[ilev - 1].begin())).bigEnd(isd)); + } + } + } + } } - ++curLevel; - curLink = nextLink; } - data = curLink->data; - xval = (0.5 + curXi) * list->dX[curLevel] + list->offsetX; - yval = *data; -} - -// ------------------------------------------------------------------- -XYPlotDataListIterator::~XYPlotDataListIterator(){ - int idx; - for(idx = 0; idx <= maxLevel; ++idx) { - delete linkLI[idx]; - } - for(idx = 0; idx != maxLevel; ++idx) { - delete XiLI[idx]; + numPoints[iCurLevel] = 0; + for(ilev = minLevel; ilev <= iCurLevel; ++ilev) { + for(BoxList::iterator bli = fillBoxLists[ilev].begin(); + bli != fillBoxLists[ilev].end(); ++bli) + { + numPoints[iCurLevel] += (*bli).length(whichDir); + } } -} + xypdlXVal[iCurLevel].resize(numPoints[iCurLevel]); + xypdlYVal[iCurLevel].resize(numPoints[iCurLevel]); - -// ------------------------------------------------------------------- -XYPlotDataListIterator &XYPlotDataListIterator::operator++() { - if(++curXi < nextXi) { - ++data; - xval += list->dX[curLevel]; - yval = *data; - return *this; + list orderedBoxes; + for(ilev = minLevel; ilev <= iCurLevel; ++ilev) { + for(BoxList::iterator bli = fillBoxLists[ilev].begin(); + bli != fillBoxLists[ilev].end(); ++bli) + { + Box refinedBox(*bli); + refinedBox.refine(AVGlobals::CRRBetweenLevels(ilev, iCurLevel, xypdlRatios)); + orderedBoxes.push_back(OrderedBoxes(ilev, whichDir, *bli, refinedBox)); + } } - - int temp; - do { - if(nextLink) { - curXi = nextLink->startXi; - curLink = nextLink; - ++curLevel; - } else { - if(curLevel != 0) { - --curLevel; - curXi = curLink->nDown; - curLink = curLink->down; - } else { - while(curLink != **linkLI[0]) { - ++(*linkLI[0]); - } - ++(*linkLI[0]); - if( ! *linkLI[0]) { - curLink = NULL; - return *this; + orderedBoxes.sort(); + int xIndex(0); + for(list::iterator obli = orderedBoxes.begin(); + obli != orderedBoxes.end(); ++obli) + { + for(int i((*obli).DataBox().smallEnd()[whichDir]); + i <= (*obli).DataBox().bigEnd()[whichDir]; ++i) + { + int obLev((*obli).ILevel()); + Real xval((0.5 + i) * dX[obLev] + offsetX); + xypdlXVal[iCurLevel][xIndex] = xval; + for(list::iterator li = (dataSets[obLev]).begin(); + li != (dataSets[obLev]).end(); ++li) + { + XYPlotDataListLink *xypd = *li; + if(i >= xypd->StartXi() && i < xypd->EndXi()) { + Real yval(xypd->XYPDLLData()[i - xypd->StartXi()]); + xypdlYVal[iCurLevel][xIndex] = yval; } - curLink = **linkLI[0]; - curXi = curLink->startXi; } + ++xIndex; } - nextXi = curLink->endXi; - if(curLevel != maxLevel && *XiLI[curLevel] && - ((temp = **XiLI[curLevel]) < nextXi)) - { - nextXi = temp; - nextLink = **linkLI[curLevel+1]; - ++(*XiLI[curLevel]); - ++(*linkLI[curLevel+1]); - } else { - nextLink = NULL; + } + + xypdlLoY[iCurLevel] = DBL_MAX; + xypdlHiY[iCurLevel] = -DBL_MAX; + for(ilev = minLevel; ilev <= iCurLevel; ++ilev) { + for(int ii(0); ii < xypdlYVal[ilev].size(); ++ii) { + xypdlLoY[iCurLevel] = min(xypdlLoY[iCurLevel], xypdlYVal[ilev][ii]); + xypdlHiY[iCurLevel] = max(xypdlHiY[iCurLevel], xypdlYVal[ilev][ii]); } - } while(curXi >= nextXi); - - data = curLink->data + (curXi - curLink->startXi); - xval = (0.5 + curXi) * list->dX[curLevel] + list->offsetX; - yval = *data; - return *this; + } + +} // end for(iCurLevel...) + + updatedQ = true; } // ------------------------------------------------------------------- // ------------------------------------------------------------------- diff --git a/XYPlotParam.cpp b/XYPlotParam.cpp index d6723a0..02d1946 100644 --- a/XYPlotParam.cpp +++ b/XYPlotParam.cpp @@ -84,7 +84,7 @@ void XYPlotParameters::ResetPalette(Palette *newPalPtr) { // ------------------------------------------------------------------- -XYPlotParameters::~XYPlotParameters(void) { +XYPlotParameters::~XYPlotParameters() { st_table_entry *ptr, *next; // destroy table entries. @@ -112,7 +112,7 @@ XYPlotParameters::~XYPlotParameters(void) { // ------------------------------------------------------------------- -void XYPlotParameters::GetHardWiredDefaults(void) { +void XYPlotParameters::GetHardWiredDefaults() { char *def_str; char buf[1024]; diff --git a/XYPlotWin.H b/XYPlotWin.H index 213b797..f433fc1 100644 --- a/XYPlotWin.H +++ b/XYPlotWin.H @@ -53,13 +53,12 @@ class XYPlotWin; typedef void (XYPlotWin::*memberXYCB)(Widget, XtPointer, XtPointer); -typedef struct legend_item_typ { +typedef struct { XYPlotDataList *XYPLIlist; - legend_item_typ *prev, *next; Widget wid; // For legend item drawingarea Widget frame; // For drawingarea frame Widget menu; // Popup menu for this item - char drawQ; + bool drawQ; int style, color; Pixel pixel; #if (BL_SPACEDIM == 2) @@ -105,8 +104,9 @@ class XYPlotWin { GC titletextGC, labeltextGC, rbGC, segGC, dotGC; // Other important numbers. - unsigned char zoomedInQ; - XYPlotLegendItem *legendHead, *legendTail, *colorChangeItem; + bool zoomedInQ; + XYPlotLegendItem *colorChangeItem; + list legendList; unsigned int numDrawnItems, numItems; unsigned char lineFormats[8]; unsigned int numXsegs; @@ -115,7 +115,8 @@ class XYPlotWin { // parameters. unsigned char markQ, tickQ, axisQ, boundBoxQ; unsigned char plotLinesQ, saveDefaultQ, dispHintsQ; - unsigned char animatingQ, tbool[7]; + bool animatingQ; + unsigned char tbool[7]; int lineW, gridW, dotW; char *XUnitText, *YUnitText, *formatX, *formatY; Pixel foregroundPix, backgroundPix, gridPix, textPix; @@ -143,6 +144,7 @@ class XYPlotWin { #endif int currFrame; + void ReattachLegendFrames(); void DoError(char *error_str) { fprintf(stderr, "%s\n", error_str); } void AddStaticCallback(Widget w, String cbtype, memberXYCB cbf, void *data = NULL); @@ -154,21 +156,21 @@ class XYPlotWin { static void StaticEvent(Widget w, XtPointer client_data, XEvent *event, char*); - void setBoundingBox(double lowX = 1.0, double lowY = 1.0, + void SetBoundingBox(double lowX = 1.0, double lowY = 1.0, double highX = 0.0, double highY = 0.0); - void updateBoundingBox(XYPlotDataList *list); + void UpdateBoundingBox(XYPlotDataList *list); void textX (Widget win, int x, int y, char *text, int just, int style); void segX(Widget win, int ns, XSegment *segs, int width, int style, int lappr, Pixel color); void dotX(Widget win, int x, int y, int style, int color); - double initGrid(double low, double high, double step); + double InitGrid(double low, double high, double step); double roundUp(double val); void writeValue(char *str, char *fmt, double val, int expv); - void CalculateBox(void); - void drawGridAndAxis(void); - void clearData(void); - void drawData(void); - void drawHint(void); + void CalculateBox(); + void drawGridAndAxis(); + void clearData(); + void drawData(); + void drawHint(); void CBdoInitializeListColorChange(Widget, XtPointer, XtPointer); void CBdoSetListColor(Widget, XtPointer, XtPointer); diff --git a/XYPlotWin.cpp b/XYPlotWin.cpp index 8b439ce..31f8914 100644 --- a/XYPlotWin.cpp +++ b/XYPlotWin.cpp @@ -30,6 +30,8 @@ #include "PltApp.H" #include "PltAppState.H" #include "GraphicsAttributes.H" +#include "AmrData.H" +#include "DataServices.H" #include #include @@ -41,6 +43,7 @@ using std::min; using std::max; #define MARK (fprintf(stderr, "Mark at file %s, line %d.\n", __FILE__, __LINE__)) +#define nlog10(x) (x == 0.0 ? 0.0 : log10(x) + 1e-15) // Hack fix for compiler bug for window manager calls #ifndef FALSE @@ -141,18 +144,17 @@ XYPlotWin::XYPlotWin(char *title, XtAppContext app, Widget w, PltApp *parent, wOptionsDialog = None; // Standard flags. - zoomedInQ = 0; + zoomedInQ = false; saveDefaultQ = 0; - animatingQ = 0; + animatingQ = false; #if (BL_SPACEDIM == 2) currFrame = 0; #endif // Create empty dataset list. - legendHead = legendTail = NULL; numDrawnItems = 0; numItems = 0; - setBoundingBox(); + SetBoundingBox(); iCurrHint = 1; @@ -349,7 +351,6 @@ XYPlotWin::XYPlotWin(char *title, XtAppContext app, Widget w, PltApp *parent, XtPopup(wXYPlotTopLevel, XtGrabNone); pWindow = XtWindow(wPlotWin); SetPalette(); - //cout << "_here 400" << endl; gaPtr = new GraphicsAttributes(wXYPlotTopLevel); disp = gaPtr->PDisplay(); vis = gaPtr->PVisual(); @@ -460,24 +461,42 @@ void XYPlotWin::InitializeAnimation(int curr_frame, int num_frames) { if(animatingQ) { return; } + PltAppState *pas = pltParent->GetPltAppState(); + Real gmin(DBL_MAX), gmax(-DBL_MAX), fmin, fmax; animatingQ = true; currFrame = curr_frame; numFrames = num_frames; - for(XYPlotLegendItem *ptr = legendHead; ptr; ptr = ptr->next) { - if(ptr->XYPLIlist->copied_from != NULL) { - XYPlotDataList *tempList = ptr->XYPLIlist; - ptr->XYPLIlist = pltParent->CreateLinePlot(ZPLANE, whichType, - ptr->XYPLIlist->maxLevel, - ptr->XYPLIlist->gridline, - &ptr->XYPLIlist->derived); + for(list::iterator ptr = legendList.begin(); + ptr != legendList.end(); ++ptr) + { + if((*ptr)->XYPLIlist->CopiedFrom() != NULL) { + XYPlotDataList *tempList = (*ptr)->XYPLIlist; + (*ptr)->XYPLIlist = pltParent->CreateLinePlot(ZPLANE, whichType, + (*ptr)->XYPLIlist->MaxLevel(), + (*ptr)->XYPLIlist->Gridline(), + &((*ptr)->XYPLIlist->DerivedName())); delete tempList; } - ptr->anim_lists = new Array(numFrames); - ptr->ready_list = new Array(numFrames, 0); + (*ptr)->anim_lists = new Array(numFrames); + (*ptr)->ready_list = new Array(numFrames, 0); + +// ================= + string sDerName = (*ptr)->XYPLIlist->DerivedName(); + const AmrData &amrData = pltParent->GetDataServicesPtr()->AmrDataRef(); + int snum = amrData.StateNumber(sDerName); + MinMaxRangeType mmrt = pas->GetMinMaxRangeType(); + for(int iframe(0); iframe < numFrames; ++iframe) { + pas->GetMinMax(mmrt, iframe, snum, fmin, fmax); + gmin = min(gmin, fmin); + gmax = max(gmax, fmax); + } +// ================= } - pltParent->GetPltAppState()->GetMinMax((Real &) lloY, (Real &) hhiY); - if( ! zoomedInQ) { - setBoundingBox(); + + lloY = gmin; + hhiY = gmax; + if(zoomedInQ == false) { + SetBoundingBox(); CBdoRedrawPlot(None, NULL, NULL); } } @@ -487,34 +506,36 @@ void XYPlotWin::InitializeAnimation(int curr_frame, int num_frames) { void XYPlotWin::UpdateFrame(int frame) { XYPlotDataList *tempList; int num_lists_changed(0); - if( ! animatingQ && ! zoomedInQ) { + if( ! animatingQ && zoomedInQ == false) { lloY = DBL_MAX; hhiY = -DBL_MAX; } - for(XYPlotLegendItem *ptr = legendHead; ptr; ptr = ptr->next) { - if(ptr->drawQ) { + for(list::iterator ptr = legendList.begin(); + ptr != legendList.end(); ++ptr) + { + if((*ptr)->drawQ == true) { ++num_lists_changed; } if(animatingQ) { - (*ptr->anim_lists)[currFrame] = ptr->XYPLIlist; - (*ptr->ready_list)[currFrame] = 1; - if((*ptr->ready_list)[frame]) { - ptr->XYPLIlist = (*ptr->anim_lists)[frame]; + (*(*ptr)->anim_lists)[currFrame] = (*ptr)->XYPLIlist; + (*(*ptr)->ready_list)[currFrame] = 1; + if((*(*ptr)->ready_list)[frame]) { + (*ptr)->XYPLIlist = (*(*ptr)->anim_lists)[frame]; continue; } } else { - tempList = ptr->XYPLIlist; + tempList = (*ptr)->XYPLIlist; } - int level(ptr->XYPLIlist->curLevel); - ptr->XYPLIlist = pltParent->CreateLinePlot(ZPLANE, whichType, - ptr->XYPLIlist->maxLevel, - ptr->XYPLIlist->gridline, - &ptr->XYPLIlist->derived); - ptr->XYPLIlist->SetLevel(level); - ptr->XYPLIlist->UpdateStats(); - if(ptr->XYPLIlist->numPoints > numXsegs) { - numXsegs = ptr->XYPLIlist->numPoints + 5; + int level((*ptr)->XYPLIlist->CurLevel()); + (*ptr)->XYPLIlist = pltParent->CreateLinePlot(ZPLANE, whichType, + (*ptr)->XYPLIlist->MaxLevel(), + (*ptr)->XYPLIlist->Gridline(), + &(*ptr)->XYPLIlist->DerivedName()); + (*ptr)->XYPLIlist->SetLevel(level); + (*ptr)->XYPLIlist->UpdateStats(); + if((*ptr)->XYPLIlist->NumPoints() > numXsegs) { + numXsegs = (*ptr)->XYPLIlist->NumPoints() + 5; delete [] Xsegs[0]; Xsegs[0] = new XSegment[numXsegs]; delete [] Xsegs[1]; @@ -522,8 +543,8 @@ void XYPlotWin::UpdateFrame(int frame) { } if( ! animatingQ) { delete tempList; - if( ! zoomedInQ && ptr->drawQ) { - updateBoundingBox(ptr->XYPLIlist); + if(zoomedInQ == false && (*ptr)->drawQ == true) { + UpdateBoundingBox((*ptr)->XYPLIlist); } } } @@ -533,10 +554,11 @@ void XYPlotWin::UpdateFrame(int frame) { } if(animatingQ) { clearData(); + drawGridAndAxis(); drawData(); } else { - if( ! zoomedInQ) { - setBoundingBox(); + if(zoomedInQ == false) { + SetBoundingBox(); } CBdoRedrawPlot(None, NULL, NULL); } @@ -545,26 +567,34 @@ void XYPlotWin::UpdateFrame(int frame) { // ------------------------------------------------------------------- void XYPlotWin::StopAnimation(void) { - if(!animatingQ) return; + if( ! animatingQ) { + return; + } animatingQ = false; - for(XYPlotLegendItem *ptr = legendHead; ptr; ptr = ptr->next) { - for(int ii = 0; ii != numFrames; ++ii) { - if((*ptr->ready_list)[ii] && (*ptr->anim_lists)[ii] != ptr->XYPLIlist) { - delete (*ptr->anim_lists)[ii]; + for(list::iterator ptr = legendList.begin(); + ptr != legendList.end(); ++ptr) + { + for(int ii(0); ii != numFrames; ++ii) { + if((*(*ptr)->ready_list)[ii] && + (*(*ptr)->anim_lists)[ii] != (*ptr)->XYPLIlist) + { + delete (*(*ptr)->anim_lists)[ii]; } } - delete ptr->ready_list; - delete ptr->anim_lists; + delete (*ptr)->ready_list; + delete (*ptr)->anim_lists; } lloY = DBL_MAX; hhiY = -DBL_MAX; - for(XYPlotLegendItem *ptr = legendHead; ptr; ptr = ptr->next) { - if(ptr->drawQ) { - updateBoundingBox(ptr->XYPLIlist); + for(list::iterator ptr = legendList.begin(); + ptr != legendList.end(); ++ptr) + { + if((*ptr)->drawQ == true) { + UpdateBoundingBox((*ptr)->XYPLIlist); } } - if( ! zoomedInQ) { - setBoundingBox(); + if(zoomedInQ == false) { + SetBoundingBox(); CBdoRedrawPlot(None, NULL, NULL); } } @@ -572,6 +602,7 @@ void XYPlotWin::StopAnimation(void) { +// ------------------------------------------------------------------- #define TRANX(xval) (((double) ((xval) - iXOrgX)) * dXUnitsPerPixel + dUsrOrgX) #define TRANY(yval) (dUsrOppY - (((double) ((yval) - iXOrgY)) * dYUnitsPerPixel)) #define SCREENX(userX) \ @@ -581,13 +612,16 @@ void XYPlotWin::StopAnimation(void) { // ------------------------------------------------------------------- -void XYPlotWin::setBoundingBox(double lowX, double lowY, - double highX, double highY) +void XYPlotWin::SetBoundingBox(double lowXIn, double lowYIn, + double highXIn, double highYIn) { + //cout << "?????????????? >>>>>> _in XYPlotWin::SetBoundingBox" << endl; + //cout << "lowXIn lowYIn highXIn highYIn = " << lowXIn << " " << lowYIn << " " << highXIn << " " << highYIn << endl; + //cout << "lloX lloY hhiX hhiY = " << lloX << " " << lloY << " " << hhiX << " " << hhiY << endl; double pad; - if(highX > lowX) { - loX = lowX; - hiX = highX; + if(highXIn > lowXIn) { + loX = lowXIn; + hiX = highXIn; } else { if(numDrawnItems == 0) { loX = -1.0; @@ -603,9 +637,9 @@ void XYPlotWin::setBoundingBox(double lowX, double lowY, loX = lloX; hiX = hhiX; } - if(highY > lowY) { - loY = lowY; - hiY = highY; + if(highYIn > lowYIn) { + loY = lowYIn; + hiY = highYIn; } else { loY = lloY; hiY = hhiY; @@ -623,7 +657,7 @@ void XYPlotWin::setBoundingBox(double lowX, double lowY, loY -= pad; } - if( ! zoomedInQ) { + if(zoomedInQ == false) { // Add 10% padding to bounding box pad = (hiX - loX) * 0.05; loX -= pad; @@ -632,6 +666,8 @@ void XYPlotWin::setBoundingBox(double lowX, double lowY, loY -= pad; hiY += pad; } + //cout << "loX loY hiX hiY = " << loX << " " << loY << " " << hiX << " " << hiY << endl; + //cout << "?????????????? <<<<<< _out XYPlotWin::SetBoundingBox" << endl; } @@ -737,10 +773,6 @@ void XYPlotWin::AddDataList(XYPlotDataList *new_list, ; // do nothing } -//j = 254; -//cout << "_here 00: j = " << j << endl; -//j = 4; - XYPlotLegendItem *new_item = new XYPlotLegendItem; new_item->XYPLIlist = new_list; @@ -771,9 +803,9 @@ void XYPlotWin::AddDataList(XYPlotDataList *new_list, pltParent->GetPalettePtr()->SetWindowPalette(pltParent->GetPaletteName(), XtWindow(new_item->wid)); Widget wid, levelmenu; - char buffer[10]; + char buffer[128]; new_item->menu = XmCreatePopupMenu(new_item->wid, "popup", NULL, 0); - if(new_list->maxLevel != 0) { + if(new_list->MaxLevel() != 0) { XmString label_str = XmStringCreateSimple("Level"); levelmenu = XmCreatePulldownMenu(new_item->menu, "pulldown", NULL, 0); XtVaCreateManagedWidget("Level", xmCascadeButtonGadgetClass, @@ -784,15 +816,14 @@ void XYPlotWin::AddDataList(XYPlotDataList *new_list, NULL); XmStringFree(label_str); - for(int ii = 0; ii <= new_list->maxLevel; ++ii) { - sprintf(buffer, "%d/%d", ii, new_list->maxLevel); + for(int ii(0); ii <= new_list->MaxLevel(); ++ii) { + sprintf(buffer, "%d/%d", ii, new_list->MaxLevel()); wid = XtVaCreateManagedWidget(buffer, xmPushButtonGadgetClass, levelmenu, NULL); if(ii < 10) { XtVaSetValues(wid, XmNmnemonic, ii + '0', NULL); } XYMenuCBData *xymenucb = new XYMenuCBData(new_item, ii); - // xymenucbdPtrs.push_back(xymenucb) int nSize(xymenucbdPtrs.size()); xymenucbdPtrs.resize(nSize + 1); xymenucbdPtrs[nSize] = xymenucb; @@ -821,38 +852,27 @@ void XYPlotWin::AddDataList(XYPlotDataList *new_list, NULL); AddStaticCallback(wid, XmNactivateCallback, &XYPlotWin::CBdoInitializeListColorChange, new_item); + + if(insert_after == NULL) { - new_item->drawQ = 1; // Default to draw. + new_item->drawQ = true; // Default to draw. ++numDrawnItems; new_list->UpdateStats(); // Find extremes, number of points. - updateBoundingBox(new_list); - if( ! zoomedInQ) { - setBoundingBox(); + UpdateBoundingBox(new_list); + if(zoomedInQ == false) { + SetBoundingBox(); } - if(new_list->numPoints > numXsegs) { - numXsegs = new_list->numPoints + 5; + if(new_list->NumPoints() > numXsegs) { + numXsegs = new_list->NumPoints() + 5; delete [] Xsegs[0]; Xsegs[0] = new XSegment[numXsegs]; delete [] Xsegs[1]; Xsegs[1] = new XSegment[numXsegs]; } - new_item->next = NULL; - if((new_item->prev = legendTail) != NULL) { - legendTail = legendTail->next = new_item; - XtVaSetValues(new_item->frame, - XmNtopAttachment, XmATTACH_WIDGET, - XmNtopWidget, new_item->prev->frame, - NULL); - } else { - legendTail = legendHead = new_item; - XtVaSetValues(new_item->frame, - XmNtopAttachment, XmATTACH_WIDGET, - XmNtopWidget, wLegendMenu, - NULL); - } + legendList.push_back(new_item); } else { new_item->drawQ = insert_after->drawQ; - if(new_item->drawQ) { + if(new_item->drawQ == true) { ++numDrawnItems; } else { XtVaSetValues(new_item->frame, @@ -860,24 +880,19 @@ void XYPlotWin::AddDataList(XYPlotDataList *new_list, XmNbottomShadowColor, backgroundPix, NULL); } - - new_item->prev = insert_after; - XtVaSetValues(new_item->frame, - XmNtopAttachment, XmATTACH_WIDGET, - XmNtopWidget, insert_after->frame, - NULL); - - if((new_item->next = insert_after->next) != NULL) { - new_item->next->prev = new_item; - XtVaSetValues(new_item->next->frame, - XmNtopAttachment, XmATTACH_WIDGET, - XmNtopWidget, new_item->frame, - NULL); - } else { - legendTail = new_item; + // find the item + for(list::iterator ptr = legendList.begin(); + ptr != legendList.end(); ++ptr) + { + if((*ptr) == insert_after) { + ++ptr; // so we can insert before + legendList.insert(ptr, new_item); + break; + } } - insert_after->next = new_item; + } + ReattachLegendFrames(); AddStaticCallback(new_item->wid, XmNinputCallback, &XYPlotWin::CBdoSelectDataList, new_item); @@ -885,41 +900,64 @@ void XYPlotWin::AddDataList(XYPlotDataList *new_list, &XYPlotWin::CBdoDrawLegendItem, new_item); XtManageChild(new_item->frame); - if(new_item->drawQ) { + if(new_item->drawQ == true) { CBdoRedrawPlot(None, NULL, NULL); } } // ------------------------------------------------------------------- -void XYPlotWin::updateBoundingBox(XYPlotDataList *xypdl) { - if(xypdl->startX < lloX) { - lloX = xypdl->startX; - } - if(xypdl->endX > hhiX) { - hhiX = xypdl->endX; - } - if(xypdl->lloY[xypdl->curLevel] < lloY) { - lloY = xypdl->lloY[xypdl->curLevel]; +void XYPlotWin::ReattachLegendFrames() { + if(legendList.empty()) { + return; } - if(xypdl->hhiY[xypdl->curLevel] > hhiY) { - hhiY = xypdl->hhiY[xypdl->curLevel]; + list::iterator liitem = legendList.begin(); + XtVaSetValues((*liitem)->frame, + XmNtopAttachment, XmATTACH_WIDGET, + XmNtopWidget, wLegendMenu, + NULL); + list::iterator liprevitem = liitem; + ++liitem; + while(liitem != legendList.end()) { + XtVaSetValues((*liitem)->frame, + XmNtopAttachment, XmATTACH_WIDGET, + XmNtopWidget, (*liprevitem)->frame, + NULL); + ++liprevitem; + ++liitem; } } - -#define nlog10(x) (x == 0.0 ? 0.0 : log10(x) + 1e-15) +// ------------------------------------------------------------------- +void XYPlotWin::UpdateBoundingBox(XYPlotDataList *xypdl) { + //cout << "???????????????????? _in XYPlotWin::UpdateBoundingBox" << endl; + if(xypdl->StartX() < lloX) { + cout << " old lloX = " << lloX << endl; + lloX = xypdl->StartX(); + cout << " new lloX = " << lloX << endl; + } + if(xypdl->EndX() > hhiX) { + hhiX = xypdl->EndX(); + } + if(xypdl->XYPDLLoY(xypdl->CurLevel()) < lloY) { + lloY = xypdl->XYPDLLoY(xypdl->CurLevel()); + } + if(xypdl->XYPDLHiY(xypdl->CurLevel()) > hhiY) { + hhiY = xypdl->XYPDLHiY(xypdl->CurLevel()); + } +} // ------------------------------------------------------------------- -double XYPlotWin::initGrid(double low, double high, double step) { +double XYPlotWin::InitGrid(double low, double high, double step) { // Hack fix for graphs of large constant graphs. Sometimes the // step is too small in comparison to the size of the grid itself, // and rounding error takes its toll. We "fix" this by multiplying // the step by an arbitrary number > 1 (1.2) when this happens. double gridHigh; + int iLoopCheck(0); while(true) { dGridStep = roundUp(step); gridHigh = (ceil(high / dGridStep) + 1.0) * dGridStep; @@ -930,6 +968,10 @@ double XYPlotWin::initGrid(double low, double high, double step) { step = DBL_EPSILON; } step *= 1.2; + ++iLoopCheck; + if(iLoopCheck > 1000) { + break; + } } dGridBase = (floor(low / dGridStep) + 1.0) * dGridStep; return dGridBase; @@ -1002,7 +1044,7 @@ void XYPlotWin::writeValue(char *str, char *fmt, double val, int expv) { // ------------------------------------------------------------------- -void XYPlotWin::drawGridAndAxis(void) { +void XYPlotWin::drawGridAndAxis() { int expX, expY; // Engineering powers int Yspot, Xspot; char value[10], final[BUFSIZE + 10]; @@ -1045,7 +1087,7 @@ void XYPlotWin::drawGridAndAxis(void) { // First, the grid line labels dYIncr = (devInfo.axisPad + devInfo.axisH) * dYUnitsPerPixel; - dYStart = initGrid(dUsrOrgY, dUsrOppY, dYIncr); + dYStart = InitGrid(dUsrOrgY, dUsrOppY, dYIncr); int iLoopCheck(0); for(dYIndex = 0.0; dYIndex < (dUsrOppY - dYStart); dYIndex += dGridStep) { Yspot = SCREENY(dYIndex + dYStart); @@ -1059,7 +1101,7 @@ void XYPlotWin::drawGridAndAxis(void) { } dXIncr = (devInfo.axisPad + (devInfo.axisW * 7)) * dXUnitsPerPixel; - dXStart = initGrid(dUsrOrgX, dUsrOppX, dXIncr); + dXStart = InitGrid(dUsrOrgX, dUsrOppX, dXIncr); iLoopCheck = 0; for(dXIndex = 0.0; dXIndex < (dUsrOppX - dXStart); dXIndex += dGridStep) { Xspot = SCREENX(dXIndex + dXStart); @@ -1075,7 +1117,7 @@ void XYPlotWin::drawGridAndAxis(void) { // Now, the grid lines or tick marks dYIncr = (devInfo.axisPad + devInfo.axisH) * dYUnitsPerPixel; - dYStart = initGrid(dUsrOrgY, dUsrOppY, dYIncr); + dYStart = InitGrid(dUsrOrgY, dUsrOppY, dYIncr); iLoopCheck = 0; for(dYIndex = 0.0; dYIndex < (dUsrOppY - dYStart); dYIndex += dGridStep) { Yspot = SCREENY(dYIndex + dYStart); @@ -1100,7 +1142,7 @@ void XYPlotWin::drawGridAndAxis(void) { } dXIncr = (devInfo.axisPad + (devInfo.axisW * 7)) * dXUnitsPerPixel; - dXStart = initGrid(dUsrOrgX, dUsrOppX, dXIncr); + dXStart = InitGrid(dUsrOrgX, dUsrOppX, dXIncr); iLoopCheck = 0; for(dXIndex = 0.0; dXIndex < (dUsrOppX - dXStart); dXIndex += dGridStep) { Xspot = SCREENX(dXIndex + dXStart); @@ -1138,15 +1180,14 @@ void XYPlotWin::drawGridAndAxis(void) { // ------------------------------------------------------------------- -void XYPlotWin::clearData(void) { +void XYPlotWin::clearData() { XClearArea(disp, pWindow, iXOrgX + 1, iXOrgY + 1, (iXOppX - iXOrgX - 2), (iXOppY - iXOrgY - 2), false); } - // ------------------------------------------------------------------- -void XYPlotWin::drawData(void) { +void XYPlotWin::drawData() { double sx1, sy1, sx2, sy2, ssx1, ssx2, ssy1, ssy2, tx(0.0), ty(0.0); int code1, code2, cd, mark_inside; unsigned int X_idx; @@ -1154,80 +1195,64 @@ void XYPlotWin::drawData(void) { int style; Pixel color; XFlush(disp); - XYPlotLegendItem *item; - for(item = legendHead; item != NULL ; item = item->next) { - if( ! item->drawQ) { + for(list::iterator item = legendList.begin(); + item != legendList.end(); ++item) + { + if((*item)->drawQ == false) { continue; } - XYPlotDataListIterator li(item->XYPLIlist); - if( ! li) { + if((*item)->XYPLIlist->NumPoints() == 0) { continue; } + Array &xvals = (*item)->XYPLIlist->XVal((*item)->XYPLIlist->CurLevel()); + Array &yvals = (*item)->XYPLIlist->YVal((*item)->XYPLIlist->CurLevel()); X_idx = 0; - style = item->style; - color = item->pixel; - sx1 = li.xval; - sy1 = li.yval; -//cout << endl << "_here 1: about to draw segments." << endl; -//cout << " maxSegs = " << devInfo.maxSegs << endl; - while(++li) { - sx2 = li.xval; - sy2 = li.yval; + style = (*item)->style; + color = (*item)->pixel; + sx1 = xvals[0]; + sy1 = yvals[0]; + for(int ili(1); ili < (*item)->XYPLIlist->NumPoints(); ++ili) { + sx2 = xvals[ili]; + sy2 = yvals[ili]; ssx1 = sx1; ssx2 = sx2; ssy1 = sy1; ssy2 = sy2; -//bool bDiag(X_idx >= 79 && X_idx <= 81); -//bool bDiag(false); -//bool bDiagLines(true); -//if(bDiag) { -//if(bDiagLines) { - //cout << "[" << X_idx << "]: sx1 sx2 = " << sx1 << " " << sx2 << endl; -//} // Put segment in (ssx1,ssy1) (ssx2,ssy2), clip to window boundary C_CODE(ssx1, ssy1, code1); C_CODE(ssx2, ssy2, code2); -//if(bDiag) { cout << " code1 code2 = " << code1 << " " << code2 << endl; } mark_inside = (code1 == 0); -//if(bDiag) { cout << " mark_inside = " << mark_inside << endl; } while(code1 || code2) { if(code1 & code2) { break; } cd = (code1 ? code1 : code2); if(cd & LEFT_CODE) { // Crosses left edge -//if(bDiag) { cout << " _here 2.LEFT" << endl; } ty = ssy1 + (ssy2 - ssy1) * (dUsrOrgX - ssx1) / (ssx2 - ssx1); tx = dUsrOrgX; } else if(cd & RIGHT_CODE) { // Crosses right edge -//if(bDiag) { cout << " _here 2.RIGHT" << endl; } ty = ssy1 + (ssy2 - ssy1) * (dUsrOppX - ssx1) / (ssx2 - ssx1); tx = dUsrOppX; } else if(cd & BOTTOM_CODE) { // Crosses bottom edge -//if(bDiag) { cout << " _here 2.BOTTOM" << endl; } tx = ssx1 + (ssx2 - ssx1) * (dUsrOrgY - ssy1) / (ssy2 - ssy1); ty = dUsrOrgY; } else if(cd & TOP_CODE) { // Crosses top edge -//if(bDiag) { cout << " _here 2.TOP" << endl; } tx = ssx1 + (ssx2 - ssx1) * (dUsrOppY - ssy1) / (ssy2 - ssy1); ty = dUsrOppY; } if(cd == code1) { -//if(bDiag) { cout << " _here 2.code1" << endl; } ssx1 = tx; ssy1 = ty; C_CODE(ssx1, ssy1, code1); } else { -//if(bDiag) { cout << " _here 2.code2" << endl; } ssx2 = tx; ssy2 = ty; C_CODE(ssx2, ssy2, code2); } } -//if(bDiag) { cout << " code1 code2 = " << code1 << " " << code2 << endl; } if( ! code1 && ! code2) { // Add segment to list Xsegs[0][X_idx].x1 = Xsegs[1][X_idx].x1; @@ -1238,22 +1263,6 @@ void XYPlotWin::drawData(void) { Xsegs[1][X_idx].y1 = SCREENY(ssy1); Xsegs[1][X_idx].x2 = SCREENX(ssx2); Xsegs[1][X_idx].y2 = SCREENY(ssy2); -/* -short xx1, xx2, yy1, yy2; -xx1 = Xsegs[1][X_idx].x1; -xx2 = Xsegs[1][X_idx].x2; -yy1 = Xsegs[1][X_idx].y1; -yy2 = Xsegs[1][X_idx].y2; -if((Xsegs[0][X_idx].x1 + Xsegs[0][X_idx].y1 + - Xsegs[0][X_idx].x2 + Xsegs[0][X_idx].y2) != 0) -{ - if(xx1 > xx2) { - cout << "[" << setw(3) << X_idx << "]" << ": x1 y1 x2 y2 = " << setw(3) - << xx1 << " " << setw(3) << yy1 << " " << setw(3) << xx2 - << " " << setw(3) << yy2 << endl; - } -} -*/ ++X_idx; } sx1 = sx2; @@ -1263,7 +1272,7 @@ if((Xsegs[0][X_idx].x1 + Xsegs[0][X_idx].y1 + dotX(wPlotWin, Xsegs[1][X_idx - 1].x1, Xsegs[1][X_idx - 1].y1, style, color); } - } + } // end while(...li) // Handle last marker if(markQ) { @@ -1282,9 +1291,7 @@ if((Xsegs[0][X_idx].x1 + Xsegs[0][X_idx].y1 + ptr += devInfo.maxSegs; X_idx -= devInfo.maxSegs; } - //if(X_idx <= 91) { segX(wPlotWin, X_idx, ptr, lineW, L_VAR, style, color); - //} } } } @@ -1385,24 +1392,23 @@ void XYPlotWin::CBdoClearData(Widget, XtPointer, XtPointer) { StopAnimation(); } #endif - XYPlotLegendItem *next; - for(XYPlotLegendItem *ptr = legendHead; ptr != NULL; ptr = next) { - next = ptr->next; - XtDestroyWidget(ptr->frame); - delete ptr->XYPLIlist; - delete ptr; + for(list::iterator item = legendList.begin(); + item != legendList.end(); ++item) + { + XtDestroyWidget((*item)->frame); + delete (*item)->XYPLIlist; + delete (*item); } + legendList.clear(); for(int idx(0); idx != 8; ++idx) { lineFormats[idx] = 0x0; } - legendHead = NULL; - legendTail = NULL; colorChangeItem = NULL; numItems = 0; numDrawnItems = 0; - zoomedInQ = 0; - setBoundingBox(); + zoomedInQ = false; + SetBoundingBox(); CBdoRedrawPlot(None, NULL, NULL); } @@ -1432,8 +1438,7 @@ void XYPlotWin::CBdoExportFileDialog(Widget, XtPointer, XtPointer) { // ------------------------------------------------------------------- void XYPlotWin::CBdoExportFile(Widget, XtPointer client_data, XtPointer data) { - XmFileSelectionBoxCallbackStruct *cbs = - (XmFileSelectionBoxCallbackStruct *) data; + XmFileSelectionBoxCallbackStruct *cbs = (XmFileSelectionBoxCallbackStruct *) data; long which = (long) client_data; FILE *fs; @@ -1518,17 +1523,21 @@ void XYPlotWin::CBdoASCIIDump(Widget, XtPointer client_data, XtPointer data) { fprintf(fs, "TickAxis: on\n"); } - for(XYPlotLegendItem *item = legendHead; item; item = item->next) { - if( ! item->drawQ) { + for(list::iterator item = legendList.begin(); + item != legendList.end(); ++item) + { + if((*item)->drawQ == false) { continue; } - XYPlotDataList *list = item->XYPLIlist; + XYPlotDataList *xypdList = (*item)->XYPLIlist; fprintf(fs, "\"%s %s Level %d/%d\n", - list->derived.c_str(), - list->intersectPoint[list->curLevel], - list->curLevel, list->maxLevel); - for(XYPlotDataListIterator li(list); li; ++li) { - fprintf(fs, "%lf %lf\n", li.xval, li.yval); + xypdList->DerivedName().c_str(), + xypdList->IntersectPoint(xypdList->CurLevel()), + xypdList->CurLevel(), xypdList->MaxLevel()); + Array &xvals = xypdList->XVal(xypdList->CurLevel()); + Array &yvals = xypdList->YVal(xypdList->CurLevel()); + for(int ii(0); ii < xvals.size(); ++ii) { + fprintf(fs, "%lf %lf\n", xvals[ii], yvals[ii]); } fprintf(fs, "\n"); } @@ -1589,7 +1598,7 @@ void XYPlotWin::CBdoOptions(Widget, XtPointer, XtPointer) { int ii; Widget wid; - char buffer[20], *str = 0; + char buffer[32], *str = 0; for(ii = 0; ii < 6; ++ii) { switch(ii) { case 0: @@ -1693,7 +1702,6 @@ void XYPlotWin::CBdoOptions(Widget, XtPointer, XtPointer) { XtManageChild(wOptionsForm); } - XtPopup(wOptionsDialog, XtGrabNone); } @@ -1780,9 +1788,11 @@ void XYPlotWin::CBdoOptionsOKButton(Widget, XtPointer data, XtPointer) { parameters->Set_Parameter("FormatY", STR, formatY); CBdoRedrawPlot(None, NULL, NULL); - for(XYPlotLegendItem *ptr = legendHead; ptr; ptr = ptr->next) { - XClearWindow(disp, XtWindow(ptr->wid)); - CBdoDrawLegendItem(None, ptr, NULL); + for(list::iterator item = legendList.begin(); + item != legendList.end(); ++item) + { + XClearWindow(disp, XtWindow((*item)->wid)); + CBdoDrawLegendItem(None, (*item), NULL); } if(saveDefaultQ) { @@ -1854,36 +1864,40 @@ void XYPlotWin::CBdoSelectDataList(Widget, XtPointer data, if(cbs->event->xany.type == ButtonRelease && cbs->event->xbutton.button == 1) { - if(item->drawQ) { - item->drawQ = 0; + if(item->drawQ == true) { + item->drawQ = false; --numDrawnItems; XtVaSetValues(item->frame, XmNtopShadowColor, backgroundPix, XmNbottomShadowColor, backgroundPix, NULL); if( ! animatingQ) { - lloX = lloY = DBL_MAX; - hhiX = hhiY = -DBL_MAX; - for(XYPlotLegendItem *ptr = legendHead; ptr; ptr = ptr->next) { - if(ptr->drawQ) { - updateBoundingBox(ptr->XYPLIlist); + lloX = DBL_MAX; + lloY = DBL_MAX; + hhiX = -DBL_MAX; + hhiY = -DBL_MAX; + for(list::iterator liitem = legendList.begin(); + liitem != legendList.end(); ++liitem) + { + if((*liitem)->drawQ == true) { + UpdateBoundingBox((*liitem)->XYPLIlist); } } } } else { - item->drawQ = 1; + item->drawQ = true; ++numDrawnItems; XtVaSetValues(item->frame, XmNtopShadowColor, foregroundPix, XmNbottomShadowColor, foregroundPix, NULL); if( ! animatingQ) { - updateBoundingBox(item->XYPLIlist); + UpdateBoundingBox(item->XYPLIlist); } } if( ! animatingQ) { - if( ! zoomedInQ) { - setBoundingBox(); + if(zoomedInQ == false) { + SetBoundingBox(); } CBdoRedrawPlot(None, NULL, NULL); } @@ -1902,62 +1916,66 @@ void XYPlotWin::CBdoSelectDataList(Widget, XtPointer data, // ------------------------------------------------------------------- void XYPlotWin::CBdoRemoveDataList(Widget, XtPointer client_data, - XtPointer call_data) { + XtPointer call_data) +{ if(animatingQ) { return; } XYPlotLegendItem *item = (XYPlotLegendItem *) client_data; - XYPlotLegendItem *ptr; + + // find the item to remove + list::iterator liitem, linextitem, liprevitem, linextitem2; + for(liitem = legendList.begin(); liitem != legendList.end(); ++liitem) { + if((*liitem) == item) { + liprevitem = liitem; + linextitem = liitem; + --liprevitem; + ++linextitem; + break; + } + } + BL_ASSERT(liitem != legendList.end()); if(item == colorChangeItem) { colorChangeItem = NULL; } - if((ptr = item->next) != NULL) { - if((ptr->prev = item->prev) != NULL) { - item->prev->next = ptr; - XtVaSetValues(ptr->frame, - XmNtopAttachment, XmATTACH_WIDGET, - XmNtopWidget, item->prev->frame, - NULL); - } else { - legendHead = ptr; - XtVaSetValues(ptr->frame, - XmNtopAttachment, XmATTACH_FORM, - NULL); - } - if(item->XYPLIlist->copied_from == NULL && - ptr->XYPLIlist->copied_from == item->XYPLIlist) + if(linextitem != legendList.end()) { + if(item->XYPLIlist->CopiedFrom() == NULL && + (*linextitem)->XYPLIlist->CopiedFrom() == item->XYPLIlist) { - ptr->XYPLIlist->copied_from = NULL; - item->XYPLIlist->copied_from = ptr->XYPLIlist; - for(XYPlotLegendItem *ptr2 = ptr->next; - ptr2 && ptr2->XYPLIlist->copied_from == item->XYPLIlist; - ptr2 = ptr2->next) + (*linextitem)->XYPLIlist->SetCopiedFrom(NULL); + item->XYPLIlist->SetCopiedFrom((*linextitem)->XYPLIlist); + linextitem2 = linextitem; + ++linextitem2; + for( ; + linextitem2 != legendList.end() && + (*linextitem2)->XYPLIlist->CopiedFrom() == item->XYPLIlist; + ++linextitem2) { - ptr2->XYPLIlist->copied_from = ptr->XYPLIlist; + (*linextitem2)->XYPLIlist->SetCopiedFrom((*linextitem)->XYPLIlist); } } - } else if((legendTail = item->prev) != NULL) { - item->prev->next = NULL; - } else { - legendHead = NULL; } char mask = 0x1 << item->color; lineFormats[item->style] &= ~mask; --numItems; - if(item->drawQ) { + if(item->drawQ == true) { --numDrawnItems; - lloX = lloY = DBL_MAX; - hhiX = hhiY = -DBL_MAX; - for(ptr = legendHead; ptr; ptr = ptr->next) { - if(ptr->drawQ) { - updateBoundingBox(ptr->XYPLIlist); + lloX = DBL_MAX; + lloY = DBL_MAX; + hhiX = -DBL_MAX; + hhiY = -DBL_MAX; + for(list::iterator liptr = legendList.begin(); + liptr != legendList.end(); ++liptr) + { + if((*liptr)->drawQ == true) { + UpdateBoundingBox((*liptr)->XYPLIlist); } } - if( ! zoomedInQ) { - setBoundingBox(); + if(zoomedInQ == false) { + SetBoundingBox(); } CBdoRedrawPlot(None, NULL, NULL); } @@ -1965,6 +1983,8 @@ void XYPlotWin::CBdoRemoveDataList(Widget, XtPointer client_data, XtDestroyWidget(item->frame); delete item->XYPLIlist; delete item; + legendList.erase(liitem); + ReattachLegendFrames(); } @@ -1989,16 +2009,20 @@ void XYPlotWin::CBdoSetListLevel(Widget, XtPointer data, XtPointer) { item->XYPLIlist->SetLevel(cbd->which); XClearWindow(disp, XtWindow(item->wid)); CBdoDrawLegendItem(None, item, NULL); - if(item->drawQ) { - lloX = lloY = DBL_MAX; - hhiX = hhiY = -DBL_MAX; - for(item = legendHead; item; item = item->next) { - if(item->drawQ) { - updateBoundingBox(item->XYPLIlist); + if(item->drawQ == true) { + lloX = DBL_MAX; + lloY = DBL_MAX; + hhiX = -DBL_MAX; + hhiY = -DBL_MAX; + for(list::iterator liitem = legendList.begin(); + liitem != legendList.end(); ++liitem) + { + if((*liitem)->drawQ == true) { + UpdateBoundingBox((*liitem)->XYPLIlist); } } - if( ! zoomedInQ) { - setBoundingBox(); + if(zoomedInQ == false) { + SetBoundingBox(); } CBdoRedrawPlot(None, NULL, NULL); } @@ -2020,8 +2044,10 @@ void XYPlotWin::SetPalette(void) { AllAttrs[idx].pixelValue = cCells[icTemp].pixel; } - for(XYPlotLegendItem *item = legendHead; item; item = item->next) { - pal->SetWindowPalette(pltParent->GetPaletteName(), XtWindow(item->wid)); + for(list::iterator liitem = legendList.begin(); + liitem != legendList.end(); ++liitem) + { + pal->SetWindowPalette(pltParent->GetPaletteName(), XtWindow((*liitem)->wid)); } } @@ -2065,21 +2091,23 @@ void XYPlotWin::CBdoSetListColor(Widget, XtPointer, XtPointer call_data) { // ------------------------------------------------------------------- void XYPlotWin::CBdoSelectAllData(Widget, XtPointer, XtPointer) { numDrawnItems = numItems; - for(XYPlotLegendItem *ptr = legendHead; ptr; ptr = ptr->next) { - if( ! ptr->drawQ) { - ptr->drawQ = 1; - XtVaSetValues(ptr->frame, + for(list::iterator ptr = legendList.begin(); + ptr != legendList.end(); ++ptr) + { + if((*ptr)->drawQ == false) { + (*ptr)->drawQ = true; + XtVaSetValues((*ptr)->frame, XmNtopShadowColor, foregroundPix, XmNbottomShadowColor, foregroundPix, NULL); if( ! animatingQ) { - updateBoundingBox(ptr->XYPLIlist); + UpdateBoundingBox((*ptr)->XYPLIlist); } } } if( ! animatingQ) { - if( ! zoomedInQ) { - setBoundingBox(); + if(zoomedInQ == false) { + SetBoundingBox(); } } CBdoRedrawPlot(None, NULL, NULL); @@ -2089,18 +2117,22 @@ void XYPlotWin::CBdoSelectAllData(Widget, XtPointer, XtPointer) { // ------------------------------------------------------------------- void XYPlotWin::CBdoDeselectAllData(Widget, XtPointer, XtPointer) { numDrawnItems = 0; - for(XYPlotLegendItem *ptr = legendHead; ptr; ptr = ptr->next) { - if(ptr->drawQ) { - ptr->drawQ = 0; - XtVaSetValues(ptr->frame, + for(list::iterator ptr = legendList.begin(); + ptr != legendList.end(); ++ptr) + { + if((*ptr)->drawQ == true) { + (*ptr)->drawQ = false; + XtVaSetValues((*ptr)->frame, XmNtopShadowColor, backgroundPix, XmNbottomShadowColor, backgroundPix, NULL); } } if( ! animatingQ) { - lloX = lloY = DBL_MAX; - hhiX = hhiY = -DBL_MAX; + lloX = DBL_MAX; + lloY = DBL_MAX; + hhiX = -DBL_MAX; + hhiY = -DBL_MAX; } CBdoRedrawPlot(None, NULL, NULL); @@ -2119,7 +2151,7 @@ void XYPlotWin::drawHint(void) { textX(wPlotWin, devInfo.areaW - 5, devInfo.bdrPad, "Left click to zoom in.", T_UPPERRIGHT, T_AXIS); - if(zoomedInQ) { + if(zoomedInQ == true) { textX(wPlotWin, devInfo.areaW - 5, devInfo.bdrPad + devInfo.axisH, "Right click to zoom out.", T_UPPERRIGHT, T_AXIS); } @@ -2137,12 +2169,8 @@ void XYPlotWin::drawHint(void) { // ------------------------------------------------------------------- void XYPlotWin::CBdoDrawLocation(Widget, XtPointer, XtPointer data) { - if(devInfo.areaW < iXLocWinX + 15 * devInfo.axisW) { - return; - } XEvent *event = (XEvent *) data; - if(event->type == LeaveNotify) { if(dispHintsQ) { iCurrHint = 1; @@ -2187,15 +2215,15 @@ void XYPlotWin::CBdoRubberBanding(Widget, XtPointer, XtPointer call_data) { // find which view from the widget w XmDrawingAreaCallbackStruct *cbs = (XmDrawingAreaCallbackStruct *) call_data; - // FIXME: - XSetForeground(disp, rbGC, 120); + Palette *pal = pltParent->GetPalettePtr(); + XSetForeground(disp, rbGC, pal->makePixel(120)); if(cbs->event->xany.type == ButtonPress) { servingButton = cbs->event->xbutton.button; if(servingButton != 1) { - if(zoomedInQ) { - zoomedInQ = 0; - setBoundingBox(); + if(zoomedInQ == true) { + zoomedInQ = false; + SetBoundingBox(); CBdoRedrawPlot(None, NULL, NULL); } return; @@ -2293,8 +2321,8 @@ void XYPlotWin::CBdoRubberBanding(Widget, XtPointer, XtPointer call_data) { highY = lowY; lowY = temp; } - zoomedInQ = 1; - setBoundingBox(lowX, lowY, highX, highY); + zoomedInQ = true; + SetBoundingBox(lowX, lowY, highX, highY); CBdoRedrawPlot(None, NULL, NULL); } else if((anchorX - newX == 0) && (anchorY - newY == 0)) { if(newX >= iXOrgX && newX <= iXOppX && newY >= iXOrgY && newY <= iXOppY) { @@ -2304,7 +2332,7 @@ void XYPlotWin::CBdoRubberBanding(Widget, XtPointer, XtPointer call_data) { hiX -= highX; loY -= highY; hiY -= highY; - zoomedInQ = 1; + zoomedInQ = true; CBdoRedrawPlot(None, NULL, NULL); } } @@ -2337,14 +2365,15 @@ void XYPlotWin::CBdoDrawLegendItem(Widget, XtPointer data, XtPointer) { char legendText[1024]; #if (BL_SPACEDIM == 3) - sprintf(legendText, "%d/%d %s", dataList->curLevel, dataList->maxLevel, - dataList->derived.c_str()); + sprintf(legendText, "%d/%d %s", dataList->CurLevel(), dataList->MaxLevel(), + dataList->DerivedName().c_str()); textX(item->wid, 5, 10, legendText, T_UPPERLEFT, T_AXIS); textX(item->wid, 5, 10 + devInfo.axisH, - dataList->intersectPoint[dataList->curLevel], T_UPPERLEFT, T_AXIS); + dataList->IntersectPoint(dataList->CurLevel()), T_UPPERLEFT, T_AXIS); #else - sprintf(legendText, "%d/%d %s %s", dataList->curLevel, dataList->maxLevel, - dataList->derived.c_str(), dataList->intersectPoint[dataList->curLevel]); + sprintf(legendText, "%d/%d %s %s", dataList->CurLevel(), dataList->MaxLevel(), + dataList->DerivedName().c_str(), + dataList->IntersectPoint(dataList->CurLevel())); textX(item->wid, 5, 10, legendText, T_UPPERLEFT, T_AXIS); #endif @@ -2367,7 +2396,6 @@ void XYPlotWin::AddStaticCallback(Widget w, String cbtype, memberXYCB cbf, void *data) { XYCBData *cbs = new XYCBData(this, data, cbf); - // xycbdPtrs.push_back(cbs) int nSize(xycbdPtrs.size()); xycbdPtrs.resize(nSize + 1); xycbdPtrs[nSize] = cbs; @@ -2383,7 +2411,6 @@ void XYPlotWin::AddStaticWMCallback(Widget w, Atom cbtype, memberXYCB cbf, void *data) { XYCBData *cbs = new XYCBData(this, data, cbf); - // xycbdPtrs.push_back(cbs) int nSize(xycbdPtrs.size()); xycbdPtrs.resize(nSize + 1); xycbdPtrs[nSize] = cbs; @@ -2399,7 +2426,6 @@ void XYPlotWin::AddStaticEventHandler(Widget w, EventMask mask, memberXYCB cbf, void *data) { XYCBData *cbs = new XYCBData(this, data, cbf); - // xycbdPtrs.push_back(cbs) int nSize(xycbdPtrs.size()); xycbdPtrs.resize(nSize + 1); xycbdPtrs[nSize] = cbs; diff --git a/amrvis.defaults b/amrvis.defaults index abecf83..d8a991a 100644 --- a/amrvis.defaults +++ b/amrvis.defaults @@ -1,8 +1,10 @@ palette Pal8.new palette Palette -initialderived tracer initialderived temp +initialderived vfrac +initialderived density initialscale 4 +initialscale 2 initialscale 1 numberformat %8.5f numberformat %8.5e @@ -13,10 +15,13 @@ maxpixmapsize 1000000 reservesystemcolors 38 reservesystemcolors 24 reservesystemcolors 34 +reservesystemcolors 0 showboxes FALSE showboxes TRUE windowheight 550 windowwidth 800 +windowheight 750 +windowwidth 900 filetype newplt lowblack cliptoppalette