/*

  Copyright (C) 2004  Betti Österholz

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2, June 1991, of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#include <iostream>
#include <sstream>
#include <string>
#include <list>


#include "CCheck.h"
#include "CDoubleOut.h"

#include "Conc.h"
#include "Function.h"
#include "Area.h"
#include "Point.h"

#include "Color.h"
#include "Position.h"
#include "UnderFunction.h"
#include "UnderArea.h"

void testmove()
{

CDoubleOut dout=CDoubleOut();
CCheck ch=CCheck();
//char yesno;


Position pos1;
pos1.setValueToValue(1, 10);
pos1.setValueToValue(2, 20);
Color col2;
col2.setValueToValue(1, 1);
col2.setValueToValue(2, 2);
col2.setValueToValue(3, 3);

//Object: p((10,20)(1,2,3))
Point p1=Point(pos1,col2);

UnderFunction *ufkt1=new UnderFunction();
ufkt1->setValueToValue(1, 1);
ufkt1->setValueToValue(2, 1);
ufkt1->setValueToValue(3, 1);

list<Vector*>* vlist=new list<Vector*>;
vlist->insert(vlist->end(),ufkt1);
Function* fkt1=new Function(&p1,*vlist);

ufkt1=new UnderFunction();
ufkt1->setValueToValue(1, 2);
ufkt1->setValueToValue(2, 2);
ufkt1->setValueToValue(3, 2);
vlist=new list<Vector*>;
vlist->insert(vlist->end(),ufkt1);
fkt1=new Function(fkt1,*vlist);

ufkt1=new UnderFunction();
ufkt1->setValueToValue(1, 3);
ufkt1->setValueToValue(2, 3);
ufkt1->setValueToValue(3, 3);
vlist=new list<Vector*>;
vlist->insert(vlist->end(),ufkt1);
fkt1=new Function(fkt1,*vlist);

unsigned int i1=0;
stringstream* strstr=new stringstream;
strstr=new stringstream;
fkt1->store(i1,*strstr);
cout<<" fkt1 : "<<strstr->str()<<endl<<flush;

dout.Print("\nfkt1->moveElement(2,2);\n");
fkt1->moveElement(2,2);

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\nfkt1->store(i1,*strstr);\n");
fkt1->store(i1,*strstr);
cout<<" fkt1 : "<<strstr->str()<<endl<<flush;


dout.Print("\nfkt1->moveElement(2,1);\n");
fkt1->moveElement(2,1);

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\nfkt1->store(i1,*strstr);\n");
fkt1->store(i1,*strstr);
cout<<" fkt1 : "<<strstr->str()<<endl<<flush;


ufkt1=new UnderFunction();
ufkt1->setValueToValue(1, 4);
ufkt1->setValueToValue(2, 4);
ufkt1->setValueToValue(3, 4);
vlist=new list<Vector*>;
vlist->insert(vlist->end(),ufkt1);
fkt1=new Function(fkt1,*vlist);

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\nfkt1->store(i1,*strstr);\n");
fkt1->store(i1,*strstr);
cout<<" fkt1 : "<<strstr->str()<<endl<<flush;

dout.Print("\nfkt1->moveElement(3,2);\n");
fkt1->moveElement(3,2);

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\nfkt1->store(i1,*strstr);\n");
fkt1->store(i1,*strstr);
cout<<" fkt1 : "<<strstr->str()<<endl<<flush;

dout.Print("\nfkt1->moveElement(1,-2);\n");
fkt1->moveElement(1,-2);

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\nfkt1->store(i1,*strstr);\n");
fkt1->store(i1,*strstr);
cout<<" fkt1 : "<<strstr->str()<<endl<<flush;


dout.Print("\nfkt1->moveElement(1,-2);\n");
fkt1->moveElement(2,-4);

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\nfkt1->store(i1,*strstr);\n");
fkt1->store(i1,*strstr);
cout<<" fkt1 : "<<strstr->str()<<endl<<flush;


//crate a object fun(fun(conc(fun(fun(fun(fun()))),fun(fun())))

PicturObject* po;

//Object: p((10,20)(1,2,3))
Point p2=Point(pos1,col2);

ufkt1=new UnderFunction();
ufkt1->setValueToValue(1, 5);
ufkt1->setValueToValue(2, 5);
ufkt1->setValueToValue(3, 5);

vlist=new list<Vector*>;
vlist->insert(vlist->end(),ufkt1);
po=new Function(&p2,*vlist);

po=new Conc(fkt1,po);

ufkt1=new UnderFunction();
ufkt1->setValueToValue(1, 6);
ufkt1->setValueToValue(2, 6);
ufkt1->setValueToValue(3, 6);

vlist=new list<Vector*>;
vlist->insert(vlist->end(),ufkt1);
po=new Function(po,*vlist);

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\npo->store(i1,*strstr);\n");
po->store(i1,*strstr);
cout<<" po : "<<strstr->str()<<endl<<flush;


dout.Print("\npo->moveElement(1,-2);\n");
po->moveElement(3,-3);

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\npo->store(i1,*strstr);\n");
po->store(i1,*strstr);
cout<<" po : "<<strstr->str()<<endl<<flush;


dout.Print("\npo->moveElement(5,1);\n");
po->moveElement(5,1);

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\npo->store(i1,*strstr);\n");
po->store(i1,*strstr);
cout<<" po : "<<strstr->str()<<endl<<flush;

dout.Print("\npo->moveElement(4,-1);\n");
po->moveElement(4,-1);

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\npo->store(i1,*strstr);\n");
po->store(i1,*strstr);
cout<<" po : "<<strstr->str()<<endl<<flush;

dout.Print("\npo->setValueToVariable(3,(po->getDefinedVariableFrom(5));\n");
po->setValueToVariable(3,(po->getDefinedVariableFrom(5)));

dout.Print("\npo->setValueToVariable(19,(po->getDefinedVariableFrom(5));\n");
po->setValueToVariable(19,(po->getDefinedVariableFrom(5)));

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\npo->store(i1,*strstr);\n");
po->store(i1,*strstr);
cout<<" po : "<<strstr->str()<<endl<<flush;

dout.Print("\npo->moveElement(5,1);\n");
po->moveElement(5,1);

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\npo->store(i1,*strstr);\n");
po->store(i1,*strstr);
cout<<" po : "<<strstr->str()<<endl<<flush;


dout.Print("\npo->moveElement(1,-5);\n");
po->moveElement(1,-5);

dout.Print("\npo->moveElement(1,-5);\n");
po->moveElement(1,-5);

dout.Print("\npo->moveElement(1,-5);\n");
po->moveElement(1,-5);
dout.Print("\npo->moveElement(1,-5);\n");
po->moveElement(1,-5);
dout.Print("\npo->moveElement(1,-5);\n");
po->moveElement(1,-5);

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\npo->store(i1,*strstr);\n");
po->store(i1,*strstr);
cout<<" po : "<<strstr->str()<<endl<<flush;

dout.Print("\npo->moveElement(1,-5);\n");
po->moveElement(4,2);
dout.Print("\npo->moveElement(1,-5);\n");
po->moveElement(4,2);

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\npo->store(i1,*strstr);\n");
po->store(i1,*strstr);
cout<<" po : "<<strstr->str()<<endl<<flush;

dout.Print("\npo->moveElement(1,8);\n");
po->moveElement(1,8);

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\npo->store(i1,*strstr);\n");
po->store(i1,*strstr);
cout<<" po : "<<strstr->str()<<endl<<flush;



dout.Print("\ndouble* var1=po->getDefinedVariableFrom(6);\n");
double* var1=po->getDefinedVariableFrom(6);
dout.Print("po->setValueToVariable(1,var1)\n");
po->setValueToVariable(1,var1);
dout.Print("po->setValueToVariable(14,var1);\n");
po->setValueToVariable(14,var1);

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\npo->store(i1,*strstr);\n");
po->store(i1,*strstr);
cout<<" po : "<<strstr->str()<<endl<<flush;

dout.Print("\npo->moveElement(6,3);\n");
po->moveElement(6,3);

i1=0;
delete strstr;
strstr=new stringstream;
dout.Print("\npo->store(i1,*strstr);\n");
po->store(i1,*strstr);
cout<<" po : "<<strstr->str()<<endl<<flush;


delete fkt1;
delete po;
};


