
//Psychlops Code Template
//    Please visit following web site to get sample codes.
//    http://psychlops.sourceforge.jp/ja/?StartCode
//    CodeDresser at following address is also available to view the code.
//    http://visitope.org/Tools/codedresser.html

///+ 0 Setup Psychlops Circumstances
//// 0 Setup Psychlops Circumstances
#include <psychlops.h>
using namespace Psychlops;
using namespace Psychlops::Utilities;
// Psychlops Win32 1.5.4 / 20110810
///- 0 Setup Psychlops Circumstances

//Widgets::Slider out_slider;

void psychlops_main() {


	///+ 1 Declaration /////////////////////////////////////////////////////////////
	//// 1 Declaration

		AppState::createSynchronousProcess("echo hoge");
		//AppState::createSynchronousProcess("echo hoge", File::decodePath("%APP%text.txt"));
		AppState::createSynchronousProcess("D:\\Users\\hskwk\\Documents\\R\\R-2.11.0\\bin\\Rscript.exe -e 'print(pi)'");

		// declare default window and variables for its parameters
		Canvas cnvs(Canvas::window, Display::secondary);
		double CANVAS_FRAMENUM;
		int CANVAS_REFRESHRATE;
		Psychlops::Color DEFAULT_BG_COLOR;

		Figures::ShaderGaborAlpha gabor;
		Psychlops::Rectangle rect;
		Psychlops::Ellipse ell;

		std::wstring ws = StringToWString("hoge");

		//declare local variables around here

	///- 1 Declaration /////////////////////////////////////////////////////////////

	///+ 2 Initialization //////////////////////////////////////////////////////////
	//// 2 Initialization

		// Set initial values for local variables
		CANVAS_REFRESHRATE = cnvs.getRefreshRate();
		CANVAS_FRAMENUM = 0;
		DEFAULT_BG_COLOR.set(127.0/255.0,127.0/255.0,127.0/255.0,1.0); // default background color is 127/255 mid-gray
		Widgets::Slider slider0, slider1, slider2, slider3;
		Widgets::Slider sliders[5];


		double a = 0.5;
		Interval rng;
		slider1.link(a, 0<=rng<=100, 1, 10).setSize(100,20).shift(0,0);
		slider2.set(toString("150") + "Name2", 0<=rng<=100, 1, 10).shift(0,50);
		slider2 = 20;
		slider3.set("Name3", 0<=rng<=1, 0.125, 0.125).shift(50,100);

		sliders[1].link(a, "hoge", 0<=rng<=1, .2);
		sliders[1].area.set(20,100).centering().shift(100,0);

		//out_slider.setLabel("out_slider").shift(200,100);


		ell.set(200,100).centering().shift(200,200);
		ell.fill = Color::green;


		gabor.setSigma(10);
		rect.set(40,10);

		// Draw Offline images around here

		// Offline Movie calculation using Image array around here

	///- 2 Initialization //////////////////////////////////////////////////////////

	///+ 3 Drawing /////////////////////////////////////////////////////////////////
	//// 3 Drawing
	while(!Input::get(Keyboard::esc)) {
		cnvs.clear(DEFAULT_BG_COLOR);


		slider1.draw();
		slider2.draw();
		slider3.draw();

		sliders[0].draw();
		sliders[1].draw();


//		out_slider.draw();

		gabor.wavelength = slider2;
		gabor.centering().draw();

		ell.draw(Color::red);

		rect.centering().shift(0,20).draw(Color::red);


		cnvs.flip();
		CANVAS_FRAMENUM++;
	}
	///- 3 Drawing /////////////////////////////////////////////////////////////////

}


