📄 fileio.cpp
字号:
{"TxtDef", typTXTDEF, &TextDef, 0L}, {"Lines", typLAST | typOBJLST, &Lines, &nLines}}; int i; switch(rw) { case SAVE_VARS: //The lines inherit settings from this object. //We need not save them in this context return SaveVarGO(Desc); case INIT_VARS: InitVarsGO(Desc); TextDef.ColTxt = 0x0L; TextDef.ColBg = 0x00ffffffL; TextDef.fSize = defs.GetSize(SIZE_TEXT); TextDef.RotBL = TextDef.RotCHAR = 0.0; TextDef.iSize = 0; TextDef.Align = TXA_VTOP | TXA_HLEFT; TextDef.Mode = TXM_TRANSPARENT; TextDef.Style = TXS_NORMAL; TextDef.Font = FONT_HELVETICA; TextDef.text = 0L; undo_flags = 0L; lspc = 1.0;
curr_z = 0.0; is3D = false; return true; case FILE_READ: ExecInput(Desc); if(Lines) for ( i = 0; i < nLines; i++) if(Lines[i]) Lines[i]->parent = this; return true; case FILE_WRITE: if(Lines) for ( i = 0; i < nLines; i++) if(Lines[i]) Lines[i]->FileIO(rw); return ExecOutput(Notary->RegisterGO(this), "mLabel", Desc); } return false;}boolsegment::FileIO(int rw){ descIO Desc[] = { {"moveable", typNZINT, &moveable, 0L}, {"cent", typLFPOINT, &fCent, 0L}, {"ri", typNZLFLOAT, &radius1, 0L}, {"ra", typLFLOAT, &radius2, 0L}, {"start", typLFLOAT, &angle1, 0L}, {"end", typLFLOAT, &angle2, 0L}, {"shout", typNZLFLOAT, &shift, 0L}, {"Line", typLINEDEF, &segLine, 0L}, {"FillLine", typLINEDEF, &segFillLine, 0L}, {"Fill", typLAST | typFILLDEF, &segFill, 0L}}; switch(rw) { case SAVE_VARS: return SaveVarGO(Desc); case INIT_VARS: InitVarsGO(Desc); segLine.width = defs.GetSize(SIZE_SEGLINE); pts = 0L; nPts = 0; return true; case FILE_READ: ExecInput(Desc); segFill.hatch = &segFillLine; return true; case FILE_WRITE: return ExecOutput(Notary->RegisterGO(this), "segment", Desc); } return false;}boolpolyline::FileIO(int rw){ descIO Desc[] = { {"Type", typNZINT, &type, 0L}, {"moveable", typNZINT, &moveable, 0L}, {"Data", typFPLST, &Values, &nPoints}, {"Line", typLINEDEF, &pgLine, 0L}, {"FillLine", typLINEDEF, &pgFillLine, 0L}, {"Fill", typLAST | typFILLDEF, &pgFill, 0L}}; switch(rw) { case INIT_VARS: InitVarsGO(Desc); memcpy(&pgLine, defs.plLineDEF(0L), sizeof(LineDEF)); memcpy(&pgFill, defs.pgFillDEF(0L), sizeof(FillDEF)); if(pgFill.hatch) memcpy(&pgFillLine, pgFill.hatch, sizeof(LineDEF)); pgFill.hatch = &pgFillLine; pts = 0L; nPts = 0; pHandles = 0L; return true; case FILE_READ: ExecInput(Desc); pgFill.hatch = &pgFillLine; return true; case FILE_WRITE: if(type != 1) Desc[3].type |= typLAST; //skip fill for polyline return ExecOutput(Notary->RegisterGO(this), type == 1 ? (char*)"polygon" : (char*)"polyline", Desc); } return false;}boolrectangle::FileIO(int rw){ descIO Desc[] = { {"Type", typNZINT, &type, 0L}, {"moveable", typNZINT, &moveable, 0L}, {"p1", typLFPOINT, &fp1, 0L}, {"p2", typLFPOINT, &fp2, 0L}, {"Line", typLINEDEF, &Line, 0L}, {"FillLine", typLINEDEF, &FillLine, 0L}, {"Fill", typFILLDEF, &Fill, 0L}, {"Rad", typNZLFLOAT, &rad, 0L}, {"Name", typLAST | typTEXT, &name, 0L}}; switch(rw) { case SAVE_VARS: return SaveVarGO(Desc); case INIT_VARS: InitVarsGO(Desc); memcpy(&Line, defs.pgLineDEF(0L), sizeof(LineDEF)); memcpy(&Fill, defs.pgFillDEF(0L), sizeof(FillDEF)); if(Fill.hatch) memcpy(&FillLine, Fill.hatch, sizeof(LineDEF)); Fill.hatch = &FillLine; pts = 0L; nPts = 0L; rad = defs.GetSize(SIZE_RRECT_RAD); drc = 0L; return true; case FILE_READ: ExecInput(Desc); Fill.hatch = &FillLine; return true; case FILE_WRITE: if(type != 2) rad = 0.0; ExecOutput(Notary->RegisterGO(this), type == 1? (char*)"ellipse" : type == 2? (char*)"roundrec" : (char*)"rectangle", Desc); return true; } return false;}
void
LegItem::RegGO(void *n)
{
if(n) {
if(Sym) Sym->RegGO(n);
if(Desc) Desc->RegGO(n);
((notary*)n)->AddRegGO(this);
}
}
boolLegItem::FileIO(int rw){ descIO Des[] = { {"D_Line", typLINEDEF, &DataLine, 0L}, {"O_Line", typLINEDEF, &OutLine, 0L}, {"H_Line", typLINEDEF, &HatchLine, 0L}, {"Fill", typFILLDEF, &Fill, 0L}, {"Sym", typGOBJ, &Sym, 0L}, {"Text", typGOBJ, &Desc, 0L}, {"flags", typLAST | typDWORD, &flags, 0L}}; switch(rw) { case SAVE_VARS: return SaveVarGO(Des); case INIT_VARS: InitVarsGO(Des); Fill.hatch = &HatchLine; return true; case FILE_READ: ExecInput(Des); Fill.hatch = &HatchLine; if(Sym) Sym->parent=this; if(Desc) Desc->parent=this; return true; case FILE_WRITE: if(Sym) Sym->FileIO(rw); if(Desc) Desc->FileIO(rw); return ExecOutput(Notary->RegisterGO(this), "LegItem", Des); } return false;}
void
Legend::RegGO(void *n)
{
int i;
if(n) {
if(Items) for(i = 0; i < nItems; i++) if(Items[i]) Items[i]->RegGO(n);
((notary*)n)->AddRegGO(this);
}
}
boolLegend::FileIO(int rw){ descIO Desc[] = { {"pos", typLFPOINT, &pos, 0L}, {"rec1", typFRECT, &B_Rect, 0L}, {"rec2", typFRECT, &D_Rect, 0L}, {"rec3", typFRECT, &F_Rect, 0L},
{"Items", typLAST | typOBJLST, &Items, &nItems}}; int i; double d; switch(rw) { case INIT_VARS: InitVarsGO(Desc); B_Rect.Ymin = defs.GetSize(SIZE_DRECT_TOP); B_Rect.Xmin = defs.GetSize(SIZE_DRECT_LEFT); B_Rect.Xmax = B_Rect.Xmin + 1.5*(d = defs.GetSize(SIZE_BAR)); B_Rect.Ymin += d*0.2; B_Rect.Ymax = B_Rect.Ymin + d/2.0; D_Rect.Ymin = 0.0; D_Rect.Xmin = d*0.7; D_Rect.Xmax = d*1.3; D_Rect.Ymax = d*0.4; F_Rect.Ymin = 0.0; F_Rect.Xmin = d*0.2;
F_Rect.Xmax = d*1.3; F_Rect.Ymax = d*0.4;
to = 0L; trc.left = trc.right = trc.top = trc.bottom = 0;
if(!name) name=strdup("Legend");
return true; case FILE_READ: nItems = 0L; ExecInput(Desc); if(Items) for(i = 0; i < nItems; i++) if(Items[i]) Items[i]->parent=this; return true; case FILE_WRITE: if(Items) for(i = 0; i < nItems; i++) if(Items[i]) Items[i]->FileIO(rw); return ExecOutput(Notary->RegisterGO(this), "Legend", Desc); } return false;}void
PlotScatt::RegGO(void *n)
{
int i;
if(n) {
if(TheLine) TheLine->RegGO(n);
if(Symbols) for(i = 0; i < nPoints; i++) if(Symbols[i]) Symbols[i]->RegGO(n);
if(Errors) for(i = 0; i < nPoints; i++) if(Errors[i]) Errors[i]->RegGO(n);
if(Arrows) for(i = 0; i < nPoints; i++) if(Arrows[i]) Arrows[i]->RegGO(n);
if(DropLines) for(i = 0; i < nPoints; i++) if(DropLines[i]) DropLines[i]->RegGO(n);
if(Labels) for(i = 0; i < nPoints; i++) if(Labels[i]) Labels[i]->RegGO(n);
if(Bars) for(i = 0; i < nPoints; i++) if(Bars[i]) Bars[i]->RegGO(n);
((notary*)n)->AddRegGO(this);
}
}
boolPlotScatt::FileIO(int rw){ descIO Desc[] = {
{"hide", typNZINT, &hidden, 0L}, {"Bounds", typFRECT, &Bounds, 0L}, {"DefSym", typNZINT, &DefSym, 0L}, {"baDist", typLFPOINT, &BarDist, 0L}, {"xRange", typTEXT, &xRange, 0L}, {"yRange", typTEXT, &yRange, 0L}, {"eRange", typTEXT, &ErrRange, 0L}, {"lRange", typTEXT, &LbRange, 0L}, {"x_axis", typNZINT, &use_xaxis, 0L}, {"y_axis", typNZINT, &use_yaxis, 0L}, {"Bars", typOBJLST, &Bars, &nPoints}, {"Symbols", typOBJLST, &Symbols, &nPoints}, {"PL", typGOBJ, &TheLine, 0L}, {"ErrBars", typOBJLST, &Errors, &nPoints}, {"Arrows", typOBJLST, &Arrows, &nPoints}, {"dLines", typOBJLST, &DropLines, &nPoints}, {"Labels", typLAST | typOBJLST, &Labels, &nPoints}}; int i;
switch(rw) { case INIT_VARS: InitVarsGO(Desc); DefSym = SYM_CIRCLE; DefSel = 0x01; dirty = true; if(name) {
sprintf(TmpTxt, "xy-plot (%s)", name);
free(name); name=strdup(TmpTxt);
}
return true; case FILE_READ: nPoints = 0L; ExecInput(Desc);
ForEach(FE_PARENT, 0L, 0L);
return true; case FILE_WRITE: if(TheLine) TheLine->FileIO(rw);
if(Symbols) for(i = 0; i < nPoints; i++) if(Symbols[i]) Symbols[i]->FileIO(rw);
if(Errors) for(i = 0; i < nPoints; i++) if(Errors[i]) Errors[i]->FileIO(rw);
if(Arrows) for(i = 0; i < nPoints; i++) if(Arrows[i]) Arrows[i]->FileIO(rw);
if(DropLines) for(i = 0; i < nPoints; i++) if(DropLines[i]) DropLines[i]->FileIO(rw);
if(Labels) for(i = 0; i < nPoints; i++) if(Labels[i]) Labels[i]->FileIO(rw);
if(Bars) for(i = 0; i < nPoints; i++) if(Bars[i]) Bars[i]->FileIO(rw);
return ExecOutput(Notary->RegisterGO(this), "PlotScatt", Desc); } return false;}
bool
xyStat::FileIO(int rw)
{
descIO Desc[] = {
{"Type", typNZINT, &type, 0L},
{"hide", typNZINT, &hidden, 0L},
{"Bounds", typFRECT, &Bounds, 0L},
{"DefSym", typNZINT, &DefSym, 0L},
{"baDist", typLFPOINT, &BarDist, 0L},
{"confi", typLFLOAT, &ci, 0L},
{"xRange", typTEXT, &xRange, 0L},
{"yRange", typTEXT, &yRange, 0L},
{"prefix", typTEXT, &case_prefix, 0L},
{"x_axis", typNZINT, &use_xaxis, 0L},
{"y_axis", typNZINT, &use_yaxis, 0L},
{"Bars", typOBJLST, &Bars, &nPoints},
{"Symbols", typOBJLST, &Symbols, &nPoints},
{"PL", typGOBJ, &TheLine, 0L},
{"ErrBars", typOBJLST, &Errors, &nPoints},
{"Labels", typLAST | typOBJLST, &Labels, &nPoints}};
int i;
switch(rw) {
case INIT_VARS:
//most initialistion is done by PlotScatt::FileIO
curr_data = 0L;
case_prefix = 0L;
ci = 95.0;
return true;
case FILE_READ:
nPoints = 0L;
ExecInput(Desc);
ForEach(FE_PARENT, 0L, 0L);
return true;
case FILE_WRITE:
if(TheLine) TheLine->FileIO(rw);
if(Symbols) for(i = 0; i < nPoints; i++) if(Symbols[i]) Symbols[i]->FileIO(rw);
if(Errors) for(i = 0; i < nPoints; i++) if(Errors[i]) Errors[i]->FileIO(rw);
if(Labels) for(i = 0; i < nPoints; i++) if(Labels[i]) Labels[i]->FileIO(rw);
if(Bars) for(i = 0; i < nPoints; i++) if(Bars[i]) Bars[i]->FileIO(rw);
return ExecOutput(Notary->RegisterGO(this), "xyStat", Desc);
}
return false;
}
void
FreqDist::RegGO(void *n)
{
int i;
if(n) {
if(plots) for(i = 0; i < nPlots; i++) if(plots[i]) plots[i]->RegGO(n);
((notary*)n)->AddRegGO(this);
}
}
bool
FreqDist::FileIO(int rw){
descIO Desc[] = {
{"Type", typNZINT, &type, 0L},
{"hide", typNZINT, &hidden, 0L},
{"ssRef", typTEXT, &ssRef, 0L},
{"x_axis", typNZINT, &use_xaxis, 0L},
{"y_axis", typNZINT, &use_yaxis, 0L},
{"cl_start", typNZLFLOAT, &start, 0L},
{"cl_size", typLFLOAT, &step, 0L},
{"BarLine", typLINEDEF, &BarLine, 0L},
{"BarFill", typFILLDEF, &BarFill, 0L},
{"BarFillLine", typLINEDEF, &HatchLine, 0L},
{"plots", typLAST | typOBJLST, &plots, &nPlots}};
int i;
switch(rw) {
case INIT_VARS:
InitVarsGO(Desc);
memcpy(&BarFill, defs.GetFill(), sizeof(FillDEF));
BarFill.color = 0x00c0ffffL;
if(BarFill.hatch) memcpy(&HatchLine, BarFill.hatch, sizeof(LineDEF));
BarFill.hatch = &HatchLine;
memcpy(&BarLine, defs.GetOutLine(), sizeof(LineDEF));
curr_data=0L;
dirty = true;
if(name) {
sprintf(TmpTxt, "freq. dist. (%s)", name);
free(name); name=strdup(TmpTxt);
}
return true;
case FILE_READ:
ExecInput(Desc);
if(plots) for(i = 0; i < nPlots; i++) if(plots[i]) plots[i]->parent=this;
return true;
case FILE_WRITE:
if(plots) for(i = 0; i < nPlots; i++) if(plots[i]) plots[i]->FileIO(rw);
return ExecOutput(Notary->RegisterGO(this), "FreqDist", Desc);
}
return false;
}
void
Regression::RegGO(void *n)
{
int i;
if(n) {
if(rLine) rLine->RegGO(n);
if(sde) sde->RegGO(n);
if(Symbols) for(i = 0; i < nPoints; i++) if(Symbols[i]) Symbols[i]->RegGO(n);
((notary*)n)->AddRegGO(this);
}
}
boolRegression::FileIO(int rw){ descIO Desc[] = { {"Type", typNZINT, &type, 0L}, {"hide", typNZINT, &hidden, 0L},
{"Bounds", typFRECT, &Bounds, 0L}, {"xRange", typTEXT, &xRange, 0L}, {"yRange", typTEXT, &yRange, 0L}, {"x_axis", typNZINT, &use_xaxis, 0L}, {"y_axis", typNZINT, &use_yaxis, 0L}, {"Line", typGOBJ, &rLine, 0L}, {"Ellipse", typGOBJ, &sde, 0L}, {"Symbols", typLAST | typOBJLST, &Symbols, &nPoints}}; int i; switch(rw) { case INIT_VARS: InitVarsGO(Desc); dirty = true; if(name) {
sprintf(TmpTxt, "regression (%s)", name);
free(name); name=strdup(TmpTxt);
}
return true; case FILE_READ: nPoints = 0L; return ExecInput(Desc); case FILE_WRITE: if(rLine) rLine->FileIO(rw); if(sde) sde->FileIO(rw); if(Symbols) for(i = 0; i < nPoints; i++) if(Symbols[i]) Symbols[i]->FileIO(rw); return ExecOutput(Notary->RegisterGO(this), "Regression", Desc); } return false;}void
BubblePlot::RegGO(void *n)
{
int i;
if(n) {
if(Bubbles) for(i = 0; i < nPoints; i++) if(Bubbles[i]) Bubbles[i]->RegGO(n);
((notary*)n)->AddRegGO(this);
}
}
boolBubblePlot::FileIO(int rw){ descIO Desc[] = { {"hide", typNZINT, &hidden, 0L},
{"Bounds", typFRECT, &Bounds, 0L}, {"x_axis", typNZINT, &use_xaxis, 0L}, {"y_axis", typNZINT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -