Skip to content

Commit

Permalink
fixed line chart problem.
Browse files Browse the repository at this point in the history
fixed some string issues.
  • Loading branch information
vince committed Aug 23, 2002
1 parent a1c0042 commit 5838561
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 233 deletions.
25 changes: 5 additions & 20 deletions Dataset.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

//
// $Id: Dataset.cpp,v 1.44 2002-08-16 00:22:33 vince Exp $
// $Id: Dataset.cpp,v 1.45 2002-08-23 00:19:36 vince Exp $
//

// ---------------------------------------------------------------
Expand Down Expand Up @@ -73,17 +73,9 @@ Dataset::Dataset(const Box &alignedRegion, AmrPicture *apptr,

// ************************************************ Dataset Window
char header[BUFSIZ];
char shortfilename[BUFSIZ];
char pltfilename[BUFSIZ];
strcpy(pltfilename, pltAppPtr->GetFileName().c_str());
int fnl(strlen(pltfilename) - 1);
while(fnl > -1 && pltfilename[fnl] != '/') {
--fnl;
}
strcpy(shortfilename, &pltfilename[fnl+1]);

ostrstream outstr(header, sizeof(header));
outstr << shortfilename << " " << pltAppStatePtr->CurrentDerived()
outstr << AVGlobals::StripSlashes(pltAppPtr->GetFileName())
<< " " << pltAppStatePtr->CurrentDerived()
<< " " << alignedRegion << ends;
wDatasetTopLevel = XtVaCreatePopupShell(header, topLevelShellWidgetClass,
pltAppPtr->WId(),
Expand Down Expand Up @@ -338,17 +330,10 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr,
int paletteEnd(palptr->PaletteEnd());

char header[BUFSIZ];
char shortfilename[BUFSIZ];
char pltfilename[BUFSIZ];
strcpy(pltfilename, pltAppPtr->GetFileName().c_str());
int fnl = strlen(pltfilename) - 1;
while(fnl>-1 && pltfilename[fnl] != '/') {
--fnl;
}
strcpy(shortfilename, &pltfilename[fnl+1]);

ostrstream outstr(header, sizeof(header));
outstr << shortfilename << " " << pltAppStatePtr->CurrentDerived()
outstr << AVGlobals::StripSlashes(pltAppPtr->GetFileName())
<< " " << pltAppStatePtr->CurrentDerived()
<< " " << alignedRegion << ends;

XtVaSetValues(wDatasetTopLevel, XmNtitle, header, NULL);
Expand Down
3 changes: 2 additions & 1 deletion GlobalUtilities.H
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

//
// $Id: GlobalUtilities.H,v 1.17 2002-08-16 00:22:33 vince Exp $
// $Id: GlobalUtilities.H,v 1.18 2002-08-23 00:19:36 vince Exp $
//

// ---------------------------------------------------------------
Expand Down Expand Up @@ -43,6 +43,7 @@ namespace AVGlobals {
int GetFileCount();
int SleepTime();
const string &GetComlineFilename(int index);
string StripSlashes(const string &inString);
FileType GetDefaultFileType();
bool GivenBox();
bool GivenBoxSlice();
Expand Down
29 changes: 28 additions & 1 deletion GlobalUtilities.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

//
// $Id: GlobalUtilities.cpp,v 1.45 2002-08-16 00:22:33 vince Exp $
// $Id: GlobalUtilities.cpp,v 1.46 2002-08-23 00:19:36 vince Exp $
//

// ---------------------------------------------------------------
Expand Down Expand Up @@ -374,6 +374,9 @@ void AVGlobals::GetDefaults(const string &defaultsFile) {
else if(strcmp(defaultString, "fixdenormals") == 0) {
RealDescriptor::SetFixDenormals();
}
else if(strcmp(defaultString, "lowblack") == 0) {
lowBlack = true;
}
else {
cout << "bad default argument: " << defaultString << endl;
}
Expand Down Expand Up @@ -907,5 +910,29 @@ int AVGlobals::DetermineMaxAllowableLevel(const Box &finestbox,
}
return(maxallowablelevel);
}


// -------------------------------------------------------------------
// this function strips slashes to try to find the true file name
// so: /d/e/f/pltname/ would return pltname
// -------------------------------------------------------------------
string AVGlobals::StripSlashes(const string &inString) {
string sTemp;
string::size_type startString, endString;
endString = inString.find_last_not_of('/');
startString = inString.find_last_of('/', endString);
if(startString == string::npos) { // no slashes found
startString = 0;
} else { // skip over the last one found
++startString;
}
sTemp = inString.substr(startString, (endString - startString + 1));

return sTemp;
}
// -------------------------------------------------------------------
// -------------------------------------------------------------------




70 changes: 23 additions & 47 deletions PltApp.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

//
// $Id: PltApp.cpp,v 1.104 2002-08-16 00:22:33 vince Exp $
// $Id: PltApp.cpp,v 1.105 2002-08-23 00:19:36 vince Exp $
//

// ---------------------------------------------------------------
Expand Down Expand Up @@ -125,10 +125,6 @@ PltApp::PltApp(XtAppContext app, Widget w, const string &filename,

char header[BUFSIZ];
ostrstream headerout(header, BUFSIZ);
int fnl(fileName.length() - 1);
while(fnl > -1 && fileName[fnl] != '/') {
--fnl;
}

if(animating2d) {
animFrames = AVGlobals::GetFileCount();
Expand All @@ -137,19 +133,15 @@ PltApp::PltApp(XtAppContext app, Widget w, const string &filename,
for(i = 0; i < animFrames; ++i) {
fileNames[i] = AVGlobals::GetComlineFilename(i);
}

// If this is an animation, putting the time in the title bar wouldn't
// make much sense. Instead, we simply indicate that this is an
// animation, and indicate the time underneath the file label in the
// controls window.
headerout << &fileName[fnl+1] << ", 2D Animation" << ends;
headerout << "2D Animation" << ends;
} else {
animFrames = 1;
fileNames.resize(animFrames);
fileNames[currentFrame] = fileName;

// Single plot file, so the time is indicated in the title bar.
headerout << &fileName[fnl+1] << ", T=" << amrData.Time() << ends;
headerout << AVGlobals::StripSlashes(fileName) << " T ="
<< amrData.Time() << ends;
}

pltAppState = new PltAppState(animFrames, amrData.NumDeriveFunc());
Expand Down Expand Up @@ -396,23 +388,18 @@ PltApp::PltApp(XtAppContext app, Widget w, const Box &region,
}
// ---------------

int fnl(fileName.length() - 1);
while (fnl>-1 && fileName[fnl] != '/') {
--fnl;
}

char timestr[32];
char timestr[64];
// If animating, do not indicate the time.
if(animating2d) {
timestr[0] = '\0';
} else {
ostrstream timeOut(timestr, 32);
timeOut << " T = " << amrData.Time() << ends;
ostrstream timeOut(timestr, 64);
timeOut << " T = " << amrData.Time() << ends;
}

ostrstream headerout(header, BUFSIZ);

headerout << &fileName[fnl+1] << timestr << " Subregion: "
headerout << AVGlobals::StripSlashes(fileName) << timestr << " Subregion: "
<< maxDomain << " on level " << maxlev << ends;

wAmrVisTopLevel = XtVaCreatePopupShell(header,
Expand Down Expand Up @@ -1021,12 +1008,9 @@ void PltApp::PltAppInit(bool bSubVolume) {
XtVaGetValues(wAnimLabelFast, XmNwidth, &slw, NULL);
XtVaSetValues(wAnimLabelFast, XmNx, wcfWidth-slw, NULL);

int fnl(fileNames[currentFrame].length() - 1);
while(fnl > -1 && fileNames[currentFrame][fnl] != '/') {
--fnl;
}

XmString fileString = XmStringCreateSimple(&fileNames[currentFrame][fnl+1]);
char cTempFN[BUFSIZ];
strcpy(cTempFN, AVGlobals::StripSlashes(fileNames[currentFrame]).c_str());
XmString fileString = XmStringCreateSimple(cTempFN);
wWhichFileLabel = XtVaCreateManagedWidget("whichFileLabel",
xmLabelWidgetClass, wControlForm,
XmNx, 0,
Expand Down Expand Up @@ -2496,9 +2480,9 @@ 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;
//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);
}
Expand Down Expand Up @@ -3465,12 +3449,9 @@ void PltApp::DoRubberBanding(Widget, XtPointer client_data, XtPointer call_data)
if(newlist) {
newlist->SetLevel(maxDrawnLevel);
if(XYplotwin[sdir] == NULL) {
int fnl(fileNames[0].length() - 1);
while(fnl > -1 && fileNames[0][fnl] != '/') {
--fnl;
}
XYplotwin[sdir] = new XYPlotWin(&fileNames[0][fnl+1],
appContext, wAmrVisTopLevel,
char cTempFN[BUFSIZ];
strcpy(cTempFN, AVGlobals::StripSlashes(fileNames[0]).c_str());
XYplotwin[sdir] = new XYPlotWin(cTempFN, appContext, wAmrVisTopLevel,
this, sdir, currentFrame);
}
XYplotwin[sdir]->AddDataList(newlist);
Expand Down Expand Up @@ -3621,12 +3602,9 @@ void PltApp::DoRubberBanding(Widget, XtPointer client_data, XtPointer call_data)
if(newlist) {
newlist->SetLevel(maxDrawnLevel);
if(XYplotwin[sdir] == NULL) {
int fnl(fileNames[0].length() - 1);
while(fnl > -1 && fileNames[0][fnl] != '/') {
--fnl;
}
XYplotwin[sdir] = new XYPlotWin(&fileNames[0][fnl+1],
appContext, wAmrVisTopLevel,
char cTempFN[BUFSIZ];
strcpy(cTempFN, AVGlobals::StripSlashes(fileNames[0]).c_str());
XYplotwin[sdir] = new XYPlotWin(cTempFN, appContext, wAmrVisTopLevel,
this, sdir, currentFrame);
}
XYplotwin[sdir]->AddDataList(newlist);
Expand Down Expand Up @@ -4118,12 +4096,10 @@ void PltApp::ShowFrame() {
amrPicturePtrArray[ZPLANE]->ImageSizeV());

string fileName(fileNames[currentFrame]);
int fnl(fileName.length() - 1);
while(fnl > -1 && fileName[fnl] != '/') {
--fnl;
}

XmString fileString = XmStringCreateSimple(&fileName[fnl+1]);
char cTempFN[BUFSIZ];
strcpy(cTempFN, AVGlobals::StripSlashes(fileName).c_str());
XmString fileString = XmStringCreateSimple(cTempFN);
XtVaSetValues(wWhichFileLabel, XmNlabelString, fileString, NULL);
XmStringFree(fileString);

Expand Down
11 changes: 3 additions & 8 deletions PltApp3D.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

//
// $Id: PltApp3D.cpp,v 1.49 2002-08-16 00:22:33 vince Exp $
// $Id: PltApp3D.cpp,v 1.50 2002-08-23 00:19:36 vince Exp $
//

// ---------------------------------------------------------------
Expand Down Expand Up @@ -222,13 +222,8 @@ void PltApp::DoDetach(Widget, XtPointer, XtPointer) {
XtVaGetValues(wAmrVisTopLevel, XmNx, &xpos, XmNy, &ypos,
XmNwidth, &wdth, XmNheight, &hght, NULL);

int fnl(fileName.length() - 1);
while(fnl > -1 && fileName[fnl] != '/') {
--fnl;
}

string outbuf = "XYZ ";
outbuf += &fileName[fnl+1];
string outbuf = "XYZ ";
outbuf += AVGlobals::StripSlashes(fileName);
strcpy(buffer, outbuf.c_str());

wDetachTopLevel = XtVaCreatePopupShell(buffer,
Expand Down
44 changes: 21 additions & 23 deletions XYPlotWin.H
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ private:
GraphicsAttributes *gaPtr;
Display *disp;
Visual *vis;
Cursor cursor,
zoomCursor;
Cursor cursor, zoomCursor;
XFontStruct *labeltextFont, *titletextFont;
GC titletextGC, labeltextGC, rbGC, segGC, dotGC;

Expand All @@ -120,36 +119,35 @@ private:
XSegment *Xsegs[2];

// parameters.
unsigned char markQ, tickQ, axisQ, boundBoxQ,
plotLinesQ, saveDefaultQ, dispHintsQ,
animatingQ, tbool[7];
unsigned char markQ, tickQ, axisQ, boundBoxQ;
unsigned char plotLinesQ, saveDefaultQ, dispHintsQ;
unsigned char animatingQ, tbool[7];
int lineW, gridW, dotW;
char *XUnitText, *YUnitText, *formatX, *formatY;
Pixel foregroundPix, backgroundPix, gridPix, textPix;
param_style gridStyle;
AttrSet AllAttrs[8];
xgOut devInfo;

Widget wLegendMenu, wLegendButtons, wPlotWin,
wOptionsDialog, wExportFileDialog, wOptionsWidgets[13];
Widget wLegendMenu, wLegendButtons, wPlotWin;
Widget wOptionsDialog, wExportFileDialog, wOptionsWidgets[13];
Window pWindow;
Atom WM_DELETE_WINDOW;

double gridBase, gridStep, gridJuke[101];
int gridNJuke, gridCurJuke;
double lloX, lloY,
hhiX, hhiY, // Global bounding box of window
loX, loY,
hiX, hiY, // Local bounding box of window
UsrOrgX,
UsrOrgY, // Origin of bounding box in user space
UsrOppX,
UsrOppY, // Other point of bounding box
XUnitsPerPixel, // X Axis scale factor
YUnitsPerPixel; // Y Axis scale factor
int XOrgX, XOrgY, // Origin of bounding box on screen
XOppX, XOppY, // Other point defining bounding box
XLocWinX, XLocWinY, currHint;
double dGridBase, dGridStep;
double lloX, lloY;
double hhiX, hhiY; // Global bounding box of window
double loX, loY;
double hiX, hiY; // Local bounding box of window
double dUsrOrgX;
double dUsrOrgY; // Origin of bounding box in user space
double dUsrOppX;
double dUsrOppY; // Other point of bounding box
double dXUnitsPerPixel; // X Axis scale factor
double dYUnitsPerPixel; // Y Axis scale factor
int iXOrgX, iXOrgY; // Origin of bounding box on screen
int iXOppX, iXOppY; // Other point defining bounding box
int iXLocWinX, iXLocWinY, iCurrHint;
#if (BL_SPACEDIM == 2)
int numFrames;
#endif
Expand Down Expand Up @@ -225,7 +223,7 @@ private:
Array<XYMenuCBData *> xymenucbdPtrs;
};

void CBcloseXYPlotWin(Widget, XtPointer, XtPointer);
void CBcloseXYPlotWin(Widget, XtPointer, XtPointer);

#endif

Loading

0 comments on commit 5838561

Please sign in to comment.