示例#1
0
TagBox::TagBox(ToolPanel *panel, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, wxString boxname, wxString modpath)
	: wxComboBox(panel, id, label, wxDefaultPosition, size)
{
	wxString filename, filepath;
	wxString readline, tag, text;
	TextFile opfile;
	bool check;

	path = modpath;
	name = boxname;
	diagbox = NULL;
	labelset = false;
	tag = "";

	if(panel->mainwin) diagbox = panel->mainwin->diagbox;

	diagbox->Write("\nTagBox init " + name + "\n");

	// tag history load
	if(name == "") {
		diagbox->Write("Tag file not set\n");
		return;
	}
	filename =  name + "tags.ini";
	check = opfile.Open(path + "/Tags/" + filename);
	if(!check) {
		if(diagbox) diagbox->Write("No tag history\n");
		return;
	}

	diagbox->Write("Reading tag history " + filename + "\n");

	readline = opfile.ReadLine();

	while(!readline.IsEmpty()) {
		//diagbox->Write("Readline " + readline + "\n");
		readline = readline.AfterFirst(' ');
		readline.Trim();
		tag = readline;
		Insert(tag, 0);
		//diagbox->Write("Insert " + tag + "\n");
		readline = opfile.ReadLine();
	}

	opfile.Close();	
	SetLabel(tag);
	diagbox->Write(name + " " + tag + "\n");
	if(tag != "") labelset = true;
}
示例#2
0
void MainFrame::MainLoad()
{
	long numdat;
	int i, check, boxindex;

	wxString filename, filepath;
	wxString readline, numstring;

	TextFile infile;
	wxPoint pos;
    wxSize size;

	//filepath = GetPath();
	filepath = "Init//";

	// Box Load
	filename = "mainbox.ini";

	check = infile.Open(filepath + filename);
	if(!check) return;
	readline = infile.ReadLine();
	//tofp.WriteLine(readline);
	while(!readline.IsEmpty()) {
		numstring = readline.BeforeFirst(' ');
		numstring.ToLong(&numdat);
		boxindex = numdat;
		if(boxindex >= toolset->numtools) break;

		pos.x = ReadNextData(&readline);
		pos.y = ReadNextData(&readline);
		size.x = ReadNextData(&readline);
		size.y = ReadNextData(&readline);
		if(toolset->box[boxindex]->servant) toolset->box[boxindex]->visible = (bool)ReadNextData(&readline);
		else toolset->box[boxindex]->visible = true;

		if(pos.x >= -5000 && pos.x < 5000 && pos.y >= -5000 && pos.y < 5000) toolset->box[boxindex]->mpos = pos;
		if(size.x >= 50 && size.x < 2000 && size.y >= 50 && size.y < 2000) toolset->box[boxindex]->boxsize = size;

		readline = infile.ReadLine();          // Read next line
		//tofp.WriteLine(readline);
	}
	infile.Close();

	for(i=0; i<toolset->numtools; i++) {
		toolset->box[i]->ReSize();
		toolset->box[i]->Show(toolset->box[i]->visible);
	}
}
示例#3
0
void GraphBase::BaseLoad(wxString path, wxString tag, wxTextCtrl *textbox)
{
	int i, index;
	TextFile infile;
	wxString readline, filename, filetag;
	wxString text, numstring, namestring, basestring;
	wxString gtag, gname;
	double numdat;
	GraphDat *graph;
	int version;

	filename = "gbase-" + tag + ".dat";

	//if(!infile.Open(initpath + "/Graphs/" + filename)) return;
	if(!infile.Open(path + "/" + filename)) return;

	if(textbox) textbox->AppendText(text.Format("Loading %d graphs\n", numgraphs));

	i = 0;
	readline = infile.ReadLine();

	// Version check

	//fileversion = ParseLong(&vstring, 'v');
	//textbox->AppendText(text.Format("Base file version %d\n", fileversion));
	//if(fileversion < version) textbox->AppendText(text.Format("Create base index\n"));

	while(!readline.IsEmpty()) {

		if(readline.GetChar(0) == 'v') version = ParseLong(&readline, 'v');          // check file version for backwards compatability
		else version = 0;
		//textbox->AppendText(text.Format("Base file version %d\n", version));
		//textbox->AppendText(text.Format("Readline %s\n", readline));

		if(version >= 2) {                                                  // Modern, reference by tag
			gtag = ParseString(&readline, 'g');
			graph = GetGraph(gtag);
			if(graph) graph->LoadDat(readline, version);
		}
		else {
			//GetGraphFromName(gname)->LoadDat(readline, version);              // Should add code to chop off any tag first
			//int ndex = readline.Find("name");
			//textbox->AppendText(text.Format("Base file version %d\n", version));
			//textbox->AppendText(text.Format("Readline %s\n", readline));
			namestring = readline.Mid(readline.Find("name"));
			//textbox->AppendText(text.Format("Name string %s\n", namestring));
			gname = ParseString(&namestring, 'e');
			gname.Replace("_", " ");
			if(textbox) textbox->AppendText(text.Format("gname %s\n", gname));
			graph = GetGraphFromName(gname);
			if(graph) graph->LoadDat(readline, version);
		}
			
		//graphstore[i].LoadDat(readline, version);
			
		if(infile.End()) break;
		readline = infile.ReadLine();	
		i++;	
	}
	infile.Close();


	// Read graphbase entries

	/*
	while(!readline.IsEmpty()) {
		graphstore[i].diagbox = mainwin->diagbox;
		graphstore[i].LoadDat(readline, version);
			
		if(infile.End()) break;
		readline = infile.ReadLine();	
		i++;	
	}
	infile.Close();
	*/
}
示例#4
0
void HypoMain::OptionLoad()
{
    long numdat;
    int check;
    
    wxString filename;
    wxString readline, numstring, tag;
    
    filename = "Init/hypoprefs.ini";
    
    wxTextFile opfile(filename);
    
    if(!opfile.Exists()) {
        startmod = 13;
        numdraw = 3;
        ylabels = 5;
        diagnostic = 1;
        datsample = 1;
        basic = 0;
    }
    else {
        
        opfile.Open();
        
        readline = opfile.GetFirstLine();
        
        while(!readline.IsEmpty()) {
            tag = readline.BeforeFirst(' ');
            readline = readline.AfterFirst(' ');
            readline.Trim();
            readline.ToLong(&numdat);
            prefstore[tag] = numdat;
            //if(diagnostic) ofp.WriteLine(text.Format("Model Param ID %d, Value %.4f\n", id, datval));
            if(opfile.Eof()) return;
            readline = opfile.GetNextLine();
        }
        
        opfile.Close();
        
        startmod = prefstore["startmod"];
        numdraw = prefstore["numdraw"];
        viewheight = prefstore["viewheight"];
        viewwidth = prefstore["viewwidth"];
        ylabels = prefstore["ylabels"];
        datsample = prefstore["datsample"];
        basic = prefstore["basic"];
        diagnostic = prefstore["diagnostic"];
        
    }
    
    filename = "Init/hypopaths.ini";
    TextFile infile;
    check = infile.Open(filename);
    
    if(!check) {
        datapath = "Data";
        parampath = "Params";
        outpath = "";
        modpath = "";
        return;
    }
    
    readline = infile.ReadLine();
    datapath = readline.Trim();
    readline = infile.ReadLine();
    parampath = readline.Trim();
    readline = infile.ReadLine();
    outpath = readline.Trim();
    readline = infile.ReadLine();
    modpath = readline.Trim();
    
    opfile.Close();
}