
#include "../libseemicro/seemicro.h"

extern "C"
{
  #include <opencv/highgui.h>
}

#include <iostream>

using namespace std;
using namespace seemicro;


// trackbars
int w = 400;
int h = 400;
int x1 =0;
int x2 =w;
int y1b =0;
int y2 =h;

IplImage *test;
polarLine l;
void redraw(int dummy=0)
{
  cvZero(test);
  cvLine(test, cvPoint(x1,y1b), cvPoint(x2,y2), CV_RGB(255,0,0));
  std::cerr << "Vor aufruf y1: " << y1b << " y2: " << y2<<std::endl;
  
  l.fromCart(w, h, cvPoint(x1,y1b), cvPoint(x2,y2));
  std::cerr << "<-\n";
  l.draw(test, CV_RGB(255, 255, 255));
  cvShowImage("Test", test);
}

int main()
{
  if(1 != cvNamedWindow("Test", 1))
  { cerr << "main(): cvNamedWindow(In): error" << endl; exit(1); }

  cvCreateTrackbar("x1", "Test", &x1, w, redraw);
  cvCreateTrackbar("y1", "Test", &y1b, h, redraw);
  cvCreateTrackbar("x2", "Test", &x2, w, redraw);
  cvCreateTrackbar("y2", "Test", &y2, h, redraw);
  test = cvCreateImage(cvSize(w,h), IPL_DEPTH_8U, 3);
  redraw();

  cout << "With this program you can test polarLine.fromCart() and polarLine.draw()\nq to quit.\n";
  int k=-1;
  while(1)
  {
    k = cvWaitKey(20);
    if(k == 'q') break;
  }
}
