Exemple #1
0
bool SaveTableSeriesActive(std::string filename,std::vector< vtkSmartPointer<vtkTable> >  table4DImage)
{

	std::vector< vtkSmartPointer<vtkTable> > tableVector;
	tableVector.clear();

	TiXmlDocument doc;
	if ( !doc.LoadFile( filename.c_str() ) )
		return false;

	TiXmlElement* rootElement = doc.FirstChildElement();
	const char* docname = rootElement->Value();
	if ( strcmp( docname, "Table" ) != 0 )
		return false;

	//Parents we know of: datafilename,resultfilename,object,parameter
	TiXmlElement* parentElement = rootElement->FirstChildElement();

	int counter = 0;

	while (parentElement)
	{
		const char * parent = parentElement->Value();
		if ( strcmp( parent, "file" ) == 0 )
		{
			SaveTable(std::string(reinterpret_cast<const char*>(parentElement->GetText())),table4DImage.at(counter) );
		}
		parentElement = parentElement->NextSiblingElement();
		counter++;
	} // end while(parentElement)
	//doc.close();
	return true;
}
Exemple #2
0
bool SaveTableSeries(std::string filename,std::vector< vtkSmartPointer<vtkTable> >  table4DImage,std::string path)
{

	std::string seriesfilename = filename ;
	TiXmlDocument doc;    
	TiXmlElement * root = new TiXmlElement( "Image" );  
	doc.LinkEndChild( root ); 
	


	for(unsigned int i = 0;	i<table4DImage.size(); ++i)				// iterate through time
	{
		// write the xml file containing the xml file names (time file names) of other xml files representing channels
		TiXmlElement * file = new TiXmlElement("file");
		std::stringstream ss;
		ss<<i;
		std::string name = path+"table_time"+ss.str()+".txt";
		SaveTable(name,table4DImage.at(i));
		file->LinkEndChild( new TiXmlText( name ) );
		std::cout<< name<<std::endl;
		root->LinkEndChild(file);
	}
	if( doc.SaveFile( seriesfilename.c_str() ) )
		return true;
	else
		return false;
}
Exemple #3
0
void RichEdit::JoinCell()
{
	if(!tablesel)
		return;
	NextUndo();
	SaveTable(tablesel);
	text.JoinCell(tablesel, cells);
	Move(text.GetCellPos(tablesel, cells.TopLeft()).pos);
}
Exemple #4
0
void RichEdit::CellProperties()
{
	if(!(tablesel || cursorp.table && !IsSelection()))
		return;
	WithCellPropertiesLayout<TopWindow> dlg;
	CtrlLayoutOKCancel(dlg, t_("Cell properties"));
	int  tab;
	Rect a;
	if(tablesel) {
		tab = tablesel;
		a = cells;
	}
	else {
		tab = cursorp.table;
		a = Rect(cursorp.cell, Size(0, 0));
	}
	RichCell::Format fmt = text.GetCellFormat(tab, a);
	CtrlRetriever r;
	r
		(dlg.leftb.SetUnit(unit), fmt.border.left)
		(dlg.rightb.SetUnit(unit), fmt.border.right)
		(dlg.topb.SetUnit(unit), fmt.border.top)
		(dlg.bottomb.SetUnit(unit), fmt.border.bottom)
		(dlg.leftm.SetUnit(unit), fmt.margin.left)
		(dlg.rightm.SetUnit(unit), fmt.margin.right)
		(dlg.topm.SetUnit(unit), fmt.margin.top)
		(dlg.bottomm.SetUnit(unit), fmt.margin.bottom)
		(dlg.align, fmt.align)
		(dlg.minheight.SetUnit(unit), fmt.minheight)
		(dlg.color, fmt.color)
		(dlg.border, fmt.bordercolor)
		(dlg.keep, fmt.keep)
		(dlg.round, fmt.round)
	;
	dlg.align.Set(0, ALIGN_TOP);
	dlg.align.Set(1, ALIGN_CENTER);
	dlg.align.Set(2, ALIGN_BOTTOM);
	dlg.color.WithVoid().VoidText(t_("(no change)"));
	dlg.border.WithVoid().VoidText(t_("(no change)"));
	if(tablesel) {
		dlg.keep.ThreeState();
		dlg.keep <<= Null;
		dlg.round.ThreeState();
		dlg.round <<= Null;
	}
	if(dlg.Run() != IDOK)
		return;
	r.Retrieve();
	NextUndo();
	SaveTable(tab);
	text.SetCellFormat(tab, a, fmt, !tablesel || !IsNull(dlg.keep), !tablesel || !IsNull(dlg.round));
	Finish();
}
Exemple #5
0
void RichEdit::TableInsertColumn()
{
	if(IsSelection() || !cursorp.table)
		return;
	NextUndo();
	SaveTable(cursorp.table);
	Point p = cursorp.cell;
	if(cursorp.cell.x == cursorp.tabsize.cx - 1 && cursorp.posincell == cursorp.celllen)
		p.x++;
	text.InsertTableColumn(cursorp.table, p.x);
	Move(text.GetCellPos(cursorp.table, text.GetMasterCell(cursorp.table, p)).pos);
}
Exemple #6
0
void RichEdit::TableRemoveColumn()
{

	if(IsSelection() || !cursorp.table)
		return;
	NextUndo();
	if(cursorp.tabsize.cx <= 1)
		DestroyTable();
	else {
		SaveTable(cursorp.table);
		text.RemoveTableColumn(cursorp.table, cursorp.cell.x);
		Move(text.GetCellPos(cursorp.table, text.GetMasterCell(cursorp.table, cursorp.cell)).pos);
	}
}
Exemple #7
0
void RichEdit::TableInsertRow()
{
	if(IsSelection() || !cursorp.table)
		return;
	NextUndo();
	SaveTable(cursorp.table);
	Point p = cursorp.cell;
	if(cursorp.posintab == cursorp.tablen) {
		p.y++;
		p.x = 0;
	}
	text.InsertTableRow(cursorp.table, p.y);
	Move(text.GetCellPos(cursorp.table, text.GetMasterCell(cursorp.table, p)).pos);
}
Exemple #8
0
void RichEdit::SplitCell()
{
	if(IsSelection() || !cursorp.table)
		return;
	WithSplitCellLayout<TopWindow> dlg;
	CtrlLayoutOKCancel(dlg, t_("Split cell"));
	dlg.cx.MinMax(1, 20).NotNull();
	dlg.cx <<= 1;
	dlg.cy.MinMax(1, 20).NotNull();
	dlg.cy <<= 1;
	if(dlg.Execute() != IDOK)
		return;
	NextUndo();
	SaveTable(cursorp.table);
	text.SplitCell(cursorp.table, cursorp.cell, Size(~dlg.cx, ~dlg.cy));
	Finish();
}
Exemple #9
0
void SavedVariables::Save(lua_State *L){

	CheckCreateSVDir();

	auto FilePath = SavedVariablesFolderPath/FileName;

	SavedVariableFile = _wfopen(FilePath.c_str(),	_T("w"));
	
	if(SavedVariableFile == NULL){
		throw exception("failed to open SavedVariable file for writing");
	}

	int ContainerIndex = LUA_GLOBALSINDEX;

	if(ContainerTable.is_valid()) {
		ContainerTable.push(L);
		ContainerIndex = lua_gettop(L);
	}

	BOOST_FOREACH(const string& VariableName, VariableNames){
		lua_getfield(L, ContainerIndex, VariableName.c_str());

		int CurrentStackPos = lua_gettop(L);

		if(lua_type(L, -1) == LUA_TNIL){
			lua_pop(L, 1);
			continue;
		}

		fprintf(SavedVariableFile, "%s = ", VariableName.c_str());

		switch(lua_type(L, -1)){
			case LUA_TNUMBER:{
        double value = lua_tonumber(L, -1);

        if(value == ((int)value)){
          fprintf(SavedVariableFile,  "%i\n", (int)value);
        }else{
          fprintf(SavedVariableFile, "%f\n", value);
        }
      }break;

			case LUA_TSTRING:
				fprintf(SavedVariableFile, "\"%s\"\n", lua_tostring(L, -1));
			break;

			case LUA_TBOOLEAN:
				fprintf(SavedVariableFile, lua_toboolean(L, -1) ? "true\n" : "false\n");
			break;

			case LUA_TTABLE:
				fprintf(SavedVariableFile, "{\n");
					SaveTable(L);
				fprintf(SavedVariableFile, "}\n");
			break;

			case LUA_TUSERDATA:
				if(SerializeCustomType(L, -1)){
					fprintf(SavedVariableFile, "\n");
				}else{
					fprintf(SavedVariableFile, "nil --[[Skipping userdata thats not a Vector or Angles]]\n");
				}
			break;

			default:
				fprintf(SavedVariableFile, "nil --Skipping a %s value that cannot be serialized]]\n", lua_typename(L, lua_type(L, -1)));
			break;
		}

		//WriteValue(L);

		_ASSERT_EXPR(lua_gettop(L) == CurrentStackPos, _T("Stack Position is not the position before the call to SaveTable"));

		lua_pop(L, 1);
	}
Exemple #10
0
CMassCalibDoc::~CMassCalibDoc()
{
	SaveTable();
}