
#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 ir =100;
int it =90;

IplImage *test;
polarLine l;

void redraw(int dummy=0)
{
  cvZero(test);
  mypoint bildmitte(200,200);
  l.r = ir;
  l.theta = it*M_PI/180;

  mypoint p1, p2;
  if(l.find_p1_p2(p1, p2, 100) != -1)
  {
    cvCircle(test, p1+bildmitte, 5, CV_RGB(200,0,255));
    cvCircle(test, p2+bildmitte, 5, CV_RGB(200,0,255));
  }
  
  l.draw(test, CV_RGB(255, 255, 255));
  cvCircle(test, bildmitte, 100, CV_RGB(200,255,255));

  cvShowImage("Test", test);
}

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

  cvCreateTrackbar("r", "Test", &ir, 200, redraw);
  cvCreateTrackbar("thetha", "Test", &it, 360, redraw);
  test = cvCreateImage(cvSize(w,h), IPL_DEPTH_8U, 3);
  redraw();

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