Exemplo n.º 1
0
void View::ClearScrren()
{
	//清除第一行
	GotoXY()(this->leftUp);
	for(int i=0;i<this->xlength;++i)
	{
		std::cout<<" ";
	}
	//清除最后一行
	GotoXY()(MyPoint(leftUp.x,leftUp.y+ylength-1));
	for( i=0;i<this->xlength;++i)
	{
		std::cout<<" ";
	}
	//清除左边
	GotoXY()(MyPoint(leftUp.x,leftUp.y+1));
	for( i=1;i<this->ylength-1;++i)
	{
		std::cout<<" \n";
	}
	//清除右边	
	for( i=1;i<this->ylength-1;++i)
	{
		GotoXY()(MyPoint(leftUp.x+xlength-1,leftUp.y+i));
		std::cout<<" ";
	}
	//清除菜单
	for(i=0;i<this->menuNum;++i)
	{
		GotoXY()(this->menuPos[i]);
		std::cout<<"          ";
	}
}
Exemplo n.º 2
0
void MatchTemplatePlugin::ProcessStatic
( int i, ImagePlus *img, ImagePlus *oimg,
 int method, CvSize winsize, IplImage* &map){
	CvRect orect = cvBoundingRect(oimg->contourArray[i],1);
	RestrictRectLoc(orect, cvRect(0,0,img->orig->width,img->orig->height));
	cvSetImageROI(oimg->orig, orect);
	CvRect rect = cvRect(MAX(0,orect.x-winsize.width), MAX(0,orect.y-winsize.height),orect.width+2*winsize.width, orect.height+2*winsize.height);
	rect.width = MIN(rect.width,oimg->orig->width-rect.x);
	rect.height = MIN(rect.height,oimg->orig->height-rect.y);
	cvSetImageROI(img->orig, rect);

	CvSize mapsize = MyPoint(MyPoint(rect)-MyPoint(orect)+wxPoint(1,1)).ToCvSize();
	if (map && MyPoint(cvGetSize(map))!=MyPoint(mapsize))
		cvReleaseImage(&map);
	if( !map )
        map = cvCreateImage(mapsize, IPL_DEPTH_32F, 1);

	cvMatchTemplate( img->orig, oimg->orig, map, method );
	cvResetImageROI(img->orig);
	cvResetImageROI(oimg->orig);
	CvPoint minloc;
	CvPoint maxloc;
	double minval, maxval;
	cvMinMaxLoc( map, &minval, &maxval, &minloc, &maxloc);
	bool minisbest = (method == CV_TM_SQDIFF || method==CV_TM_SQDIFF_NORMED);
	rect.x = rect.x + (minisbest ? minloc.x : maxloc.x);
	rect.y = rect.y + (minisbest ? minloc.y : maxloc.y);

	CvPoint shift = cvPoint(rect.x - orect.x, rect.y - orect.y);
	ShiftContour(oimg->contourArray[i],img->contourArray[i],shift);
	ShiftFeatPoints(oimg->feats[i], img->feats[i], cvPointTo32f(shift));
}
Exemplo n.º 3
0
void View::DisPlay()
{
	this->SetColor(this->color);
	//打印第一行
	GotoXY()(MyPoint(leftUp.x,leftUp.y+1));
	for(int i=0;i<this->xlength;++i)
	{
		std::cout<<"-";
	}
	//打印最后一行
	GotoXY()(MyPoint(leftUp.x,leftUp.y+ylength-1));
	for( i=0;i<this->xlength;++i)
	{
		std::cout<<"-";
	}
	//打印左边
	GotoXY()(MyPoint(leftUp.x,leftUp.y+1));
	for(i=1;i<this->ylength-1;++i)
	{
		std::cout<<"|\n";
	}
	//打印右边	
	for( i=1;i<this->ylength-1;++i)
	{
		GotoXY()(MyPoint(leftUp.x+xlength-1,leftUp.y+i));
		std::cout<<"|";
	}
	//打印菜单
	for(i=0;i<this->menuNum;++i)
	{
		GotoXY()(this->menuPos[i]);
		std::cout<<this->menuName[i];
	}
}
Exemplo n.º 4
0
void CaptureManager::Resize(int width, int height, int method)
{
	if (MyPoint(width,height) == MyPoint(size))
		return;
	size = cvSize(width,height);
	for (int i=0; i<totalFrameCount; i++)
	{
		book[i]->Resize(width, height, method);
	}
	ReloadCurrentFrame();
}
Exemplo n.º 5
0
bool CaptureManager::SaveTrajectoryImage(wxBitmap &bmp)
{
	if (!Access(0,0, false, true)->contourArray.size())
	{
		wxLogError(_T("No objects in the first frame. Detect/draw boundaries in the first frame and apply tracking first."));
		return false;
	}
	wxRealPoint scale(6,6);
	CvPoint lastLoc;
	bmp.Create(scale.x*size.width,scale.y*size.height);
	wxMemoryDC dc(bmp);
	dc.SetBackground(*wxWHITE_BRUSH);
	dc.Clear();
	for (int c=0; c<Access(0,0,false, true)->contourArray.size(); c++)
	{
		std::vector<CvPoint> traj = GetTrajectory(c);
		lastLoc = traj[0];
		// draw first boundary
		MyCanvas::DrawContour_static(&dc, Access(0,0, false, true)->contourArray[c],wxPoint(0,0),scale);
		// drawing trajectory lines
		dc.SetBrush(*wxTRANSPARENT_BRUSH);
		for (int i=1; i<traj.size(); i++)
		{
			if(traj[i].x<0)
				continue;
			if (i>0)
			{
				dc.SetPen(wxPen(wxColour(Preferences::GetColorContourBorderColor()), Preferences::GetColorContourBorderWidth()));
				dc.DrawLine(scale.x*lastLoc.x,scale.y*lastLoc.y, scale.x*traj[i].x,scale.y*traj[i].y);
			}
			lastLoc = traj[i];
		}
		// drawing trajectory points
		dc.SetBrush(wxBrush(wxColour(Preferences::GetColorContourPointColor())));
		dc.SetPen(wxPen(wxColour(Preferences::GetColorContourPointColor())));
		for (int i=0; i<traj.size(); i++)
		{
			if(traj[i].x<0)
				continue;
			dc.DrawCircle(MyPoint(traj[i])*scale, 2*Preferences::GetColorContourBorderWidth());
		}
		// draw last boundary
		dc.SetBrush(*wxRED_BRUSH);
		dc.SetPen(wxPen(*wxRED));
		if(traj[frameCount-1].x>=0)
		{
			dc.DrawCircle(MyPoint(traj[frameCount-1])*scale, 2*Preferences::GetColorContourBorderWidth());
			MyCanvas::DrawContour_static(&dc, book[(frameCount-1)*offset]->contourArray[c],wxPoint(0,0),scale, true, wxRED);
		}
	}
	return true;
}
Exemplo n.º 6
0
std::vector<double> CaptureManager::GetDeformation(int c, float &avgDef)
{
	std::vector<CvPoint> traj = GetTrajectory(c);
	std::vector<double> areas = GetAreas(c,avgDef);
	std::vector<double> defs(frameCount-1, 0.0);
	float totalDef = 0;
	int goodSteps = 0;
	CvSeq *h_next;
	ImagePlus *img_ = new ImagePlus(img);
	IplImage *gray = cvCreateImage(cvGetSize(img.orig), IPL_DEPTH_8U, 1);
	IplImage *edge = cvCreateImage(cvGetSize(img.orig), IPL_DEPTH_8U, 1);
	for (int i=0; i<frameCount-1; i++)
	{
		if (!(MyPoint(-1,-1)==traj[i] || MyPoint(-1,-1)==traj[i+1]))
		{
			wxPoint *ps = ContourToPointArray(Access(i,0,false, true)->contourArray[c], MyPoint(traj[i+1])-MyPoint(traj[i]).ToWxPoint());
			img_->RemoveAllContours();
			img_->AddContour(ps,Access(i,0,false, true)->contourArray[c]->total);
			delete[] ps;

			CvSeq *seq = Access(i+1,0,false, true)->contourArray[c];
			CvSeq *oseq = img_->contourArray[0];
			//Draw both contours on the temporary image
			cvZero(img_->orig);
			h_next = seq->h_next; seq->h_next = NULL;
			cvDrawContours(img_->orig, seq, CV_RGB(255,255,255), CV_RGB(0,0,0), 1, CV_FILLED, CV_AA, cvPoint(0,0));
			seq->h_next = h_next;
			cvDrawContours(img_->orig, oseq, CV_RGB(255,255,200), CV_RGB(0,0,0), 1, CV_FILLED, CV_AA, cvPoint(0,0));

			//detect contours on the drawn image:
			FindContoursPlugin::ProcessImage_static(img_,gray,edge,150,50,3,1);
			float unionArea = 0;
			for (int j=0; j<img_->contourArray.size(); j++)
			{
				unionArea += fabs(cvContourArea(img_->contourArray[j]));
			}

			goodSteps++;
			totalDef += (defs[i] = 2*unionArea - areas[i] - areas[i+1]);
		}
	}
	cvReleaseImage(&gray);
	cvReleaseImage(&edge);
	delete img_;
	avgDef = (goodSteps ? totalDef/goodSteps : 0);
	return defs;
}
MyRectangle::MyRectangle(float posX = 0, float posY = 0, float posZ = 0, float height = 1, float width = 1, float rotX = 0, float rotY = 0, float rotZ = 0) {

	MyTriangle* triA = new MyTriangle(posX, posY, posZ, height, width, rotX, rotY, rotZ);
	triA->mapTexture(0, 0.f, 0.f);
	triA->mapTexture(1, 1.f, 0.f);
	triA->mapTexture(2, 1.f, 1.f);

	MyTriangle* triB = new MyTriangle(MyPoint(posX, posY, posZ), MyPoint(posX, posY+height, posZ), MyPoint(posX+width,posY+height,posZ));
	triB->flipNormals();
	triB->calculateNormal();
	triB->mapTexture(0, 0.f, 0.f);
	triB->mapTexture(1, 0.f, 1.f);
	triB->mapTexture(2, 1.f, 1.f);

	this->add(triA);
	this->add(triB);
}
Exemplo n.º 8
0
void initCamera(void){
	u = vec3(1,0,0);
	v = vec3(0,1,0);
	n = vec3(0,0,1);
	eye = MyPoint(0,-.7,3.3,1);

	MySetModelViewMatrix();
}
Exemplo n.º 9
0
std::vector<double> CaptureManager::GetSpeeds(int c, float &totalDisp, float &avgSpeed)
{
	std::vector<CvPoint> traj = GetTrajectory(c);
	std::vector<double> s(frameCount-1, 0.0);
	totalDisp = 0;
	int goodSteps = 0;
	for (int i=0; i<frameCount-1; i++)
	{
		if (!(MyPoint(-1,-1)==traj[i] || MyPoint(-1,-1)==traj[i+1]))
		{
			goodSteps++;
			totalDisp += (s[i] = MyPoint(traj[i]).Euclidean(MyPoint(traj[i+1])));
		}
	}
	avgSpeed = (goodSteps ? totalDisp/goodSteps : 0);
	return s;
}
Exemplo n.º 10
0
int main(int argc, char **argv)
{
    int width = 100; // y
    int height = 100; // x
    int depth = 5;
    int colors = 2; // Colors

    int len = width * height * colors * depth;
    std::vector<MyPoint> pts;
    pts.reserve(len);

    for (int c=0; c<colors; ++c)
        for (int d=0; d<depth; ++d)
            for (int y=0; y<height; ++y)
                for (int x=0; x<width; ++x)
                    pts.push_back(MyPoint(c, x, y, d));
    // print(pts);
    
    std::vector<MyPoint> pts_sorted(pts);

    std::random_shuffle(pts.begin(), pts.end());
    
    std::vector<MyPoint> pts_shuffled(pts);

    // Using std::stable_sort
    std::stable_sort(pts.begin(), pts.end(), mypoint_x_sort_fn);
    std::stable_sort(pts.begin(), pts.end(), mypoint_y_sort_fn);
    std::stable_sort(pts.begin(), pts.end(), mypoint_d_sort_fn);    
    std::stable_sort(pts.begin(), pts.end(), mypoint_c_sort_fn);

    if (pts == pts_sorted)
        std::cerr << "Stable sort OK" << std::endl;
    else
        std::cerr << "Stable sort FAIL" << std::endl;
    
    // Using std::sort
    pts = pts_shuffled;

    std::sort(pts.begin(), pts.end(), mypoint_all_sort_fn);
    if (pts == pts_sorted)
        std::cerr << "Sort OK" << std::endl;
    else
        std::cerr << "Sort FAIL" << std::endl;

    // Templates world
    pts = pts_shuffled;
    
    std::sort(pts.begin(), pts.end(), mypoint_sort);
    if (pts == pts_sorted)
        std::cerr << "Sort OK" << std::endl;
    else
        std::cerr << "Sort FAIL" << std::endl;

    return 0;
}
Exemplo n.º 11
0
void tst_QDebug::debugSpaceHandling() const
{
    MessageHandlerSetter mhs(myMessageHandler);
    {
        QDebug d = qDebug();
        QVERIFY(d.autoInsertSpaces());
        d.setAutoInsertSpaces(false);
        QVERIFY(!d.autoInsertSpaces());
        d << "  ";
        d.setAutoInsertSpaces(true);
        QVERIFY(d.autoInsertSpaces());
        d << "foo";
        d.nospace();
        d << "key=" << "value";
        d.space();
        d << 1 << 2;
        MyLine line(MyPoint(10, 11), MyPoint (12, 13));
        d << line;
        // With the old implementation of MyPoint doing dbg.nospace() << ...; dbg.space() we ended up with
        // MyLine(MyPoint(10, 11) ,  MyPoint(12, 13) )
    }
    QCOMPARE(s_msg, QString::fromLatin1("  foo key=value 1 2 MyLine(MyPoint(10, 11), MyPoint(12, 13))"));
}
Exemplo n.º 12
0
// Generates a PLYPicture of a cube
PLYPicture* generatePLYCube(void){
	PLYPicture* pic = generateEmptyPLYPicture(8, 12);
	MyPoint* pts = pic->points->pt;

	MyPoint vertices[8] = {
		MyPoint( -0.5, -0.5,  0.5, 1.0 ),
		MyPoint( -0.5,  0.5,  0.5, 1.0 ),
		MyPoint(  0.5,  0.5,  0.5, 1.0 ),
		MyPoint(  0.5, -0.5,  0.5, 1.0 ),
		MyPoint( -0.5, -0.5, -0.5, 1.0 ),
		MyPoint( -0.5,  0.5, -0.5, 1.0 ),
		MyPoint(  0.5,  0.5, -0.5, 1.0 ),
		MyPoint(  0.5, -0.5, -0.5, 1.0 )
	};

	// Save in the vertices
	int i;
	for (i = 0; i < 8; i++){
		pts[i] = vertices[i];
	}

	// save in the triangles
	pic->triangles[0] = vec3(1, 0, 3);
	pic->triangles[1] = vec3(2, 3, 7);
	pic->triangles[2] = vec3(3, 0, 4);
	pic->triangles[3] = vec3(6, 5, 1);
	pic->triangles[4] = vec3(4, 5, 6);
	pic->triangles[5] = vec3(5, 4, 0);

	pic->triangles[6]  = vec3(1, 3, 2);
	pic->triangles[7]  = vec3(2, 7, 6);
	pic->triangles[8]  = vec3(3, 4, 7);
	pic->triangles[9]  = vec3(6, 1, 2);
	pic->triangles[10] = vec3(4, 6, 7);
	pic->triangles[11] = vec3(5, 0, 1);

	// Boundaries
	pic->max = vec3(.5, .5, .5);
	pic->min = vec3(-.5,-.5,-.5);

	return pic;
}
	int maxArea(vector<int> const &height) {
		vector<MyPoint> points(height.size());
		for (int i = 0; i < (int)points.size(); ++i) {
			points[i] = MyPoint(i, height[i]);
		}

		sort(points.begin(), points.end(), [](MyPoint const &a, MyPoint const &b){
			return a.y < b.y;
		});

		int result = 0;
		int minX = points.back().x, maxX = points.back().x;
		for (int i = points.size() - 2; i >= 0; --i) {
			auto p = points[i];
			result = max(result, p.y * max(abs(p.x - minX), abs(p.x - maxX)));
			minX = min(minX, p.x);
			maxX = max(maxX, p.x);
		}

		return result;
	}
Exemplo n.º 14
0
int main()
{
  std::vector< MyPoint > points;

  points.push_back(MyPoint(14,12, 3));
  points.push_back(MyPoint(1,2  , 0));
  points.push_back(MyPoint(414,2, 5));
  points.push_back(MyPoint(4,21 , 1));
  points.push_back(MyPoint(7,74 , 2));
  points.push_back(MyPoint(74,4 , 4));  
  
  MySpatialSortingTraits sst;
  CGAL::spatial_sort(points.begin(), points.end(), sst);

  for (std::vector< MyPoint >::iterator it=points.begin();it!=points.end();++it)
    std::cout << it->color << " ";
  std::cout << "\n";  
  
  std::cerr << "done" << std::endl;
  return 0;
}
Exemplo n.º 15
0
void Bottle::beforeMatch(int i, int j)
{
    if(_state<0) return;
    
    
    if(j + 1 < kMatrixWidth)
    {
        if (_gemStoneMatrix[i][j+1])
        {
            GemType type = (GemType)((_type - redbottle) / 5 + 1);
            if (_gemStoneMatrix[i][j+1]->getGemType() == type && _gemStoneMatrix[i][j+1]->getState() != -1)
            {
                _state-- ;
                MyPoint mp = MyPoint(i, j + 1);
                _gemStoneMatrix[i][j+1]->explode(mp, mp, 0, 0);
                
                AnimationWraper aw(NULL, e_aid_normal_explode, e_priority_normal_explode);
                
                _animationWraperVector->push_back(aw);
                
                __String *str = __String::create("");
                if (_state == 2)
                {
                    if (type == red )
                    {
                        str = __String::create("bottle1_red.png");
                    }
                    else if (type == yellow)
                    {
                        str = __String::create("bottle1_yellow.png");
                    }
                    else if (type == blue)
                    {
                        _state = 2;
                        str = __String::create("bottle1_blue.png");
                    }
                    else if (type == green)
                    {
                        str = __String::create("bottle1_green.png");
                    }
                    else if (type == purple)
                    {
                        str = __String::create("bottle1_purple.png");
                    }
                    else if (type == white)
                    {
                        str = __String::create("bottle1_white.png");
                    }
                }
                else if(_state == 1)
                {
                    if (type == red)
                    {
                        str = __String::create("bottle2_red.png");
                    }
                    else if (type == yellow)
                    {
                        str = __String::create("bottle2_yellow.png");
                    }
                    else if (type == blue)
                    {
                        str = __String::create("bottle2_blue.png");
                    }
                    else if (type == green)
                    {
                        str = __String::create("bottle2_green.png");
                    }
                    else if (type == purple)
                    {
                        str = __String::create("bottle2_purple.png");
                    }
                    else if (type == white)
                    {
                        str = __String::create("bottle2_white.png");
                    }

                }
                else if(_state == 0)
                {
                    if (type == red)
                    {
                        str = __String::create("bottle3_red.png");
                    }
                    else if (type == yellow)
                    {
                        str = __String::create("bottle3_yellow.png");
                    }
                    else if (type == blue)
                    {
                        str = __String::create("bottle3_blue.png");
                    }
                    else if (type == green)
                    {
                        str = __String::create("bottle3_green.png");
                    }
                    else if (type == purple)
                    {
                        str = __String::create("bottle3_purple.png");
                    }
                    else if (type == white)
                    {
                        str = __String::create("bottle3_white.png");
                    }
                }
                else if(_state == -1)
                {
                    if (type == red)
                    {
                        str = __String::create("bottle4_red.png");
                    }
                    else if (type == yellow)
                    {
                        str = __String::create("bottle4_yellow.png");
                    }
                    else if (type == blue)
                    {
                        str = __String::create("bottle4_blue.png");
                    }
                    else if (type == green)
                    {
                        str = __String::create("bottle4_green.png");
                    }
                    else if (type == purple)
                    {
                        str = __String::create("bottle4_purple.png");
                    }
                    else if (type == white)
                    {
                        str = __String::create("bottle4_white.png");
                    }
                }
                _spr->setTexture(str->getCString());
            }
        }
        
        if (_state == -1)
        {
            AnimationWraper aw2(NULL,e_aid_normal_explode,e_priority_normal_explode);
            
            _animationWraperVector->push_back(aw2);
        }
    }
}
Exemplo n.º 16
0
#include "Angel.h"  // Angel.h is homegrown include file, which also includes glew and freeglut
#include "utils.h"



// Camera Position variables
MyPoint eye = MyPoint(0,0,.3,1);
vec3 u,v,n;
mat4 NewCamera;


mat4 getCamera(void){
	return NewCamera;
}


void MySetModelViewMatrix(void)
{ // load modelview matrix with camera values
	mat4 m;
	vec3 eVec(eye.x, eye.y, 	eye.z);// eye as vector
	m[0][0] = u.x; m[0][1] = u.y; m[0][2] = 	u.z; m[0][3] = -dot(eVec,u);
	m[1][0] = v.x; m[1][1] = v.y; m[1][2] = 	v.z; m[1][3] = -dot(eVec,v);
	m[2][0] = n.x; m[2][1] = n.y; m[2][2] = n.z; m[2][3] = -dot(eVec,n);
	m[3][0] = 0;   m[3][1] =   0; m[3][2] =   0; m[3][3] = 1.0;
	NewCamera = m;
	printm(NewCamera);
}

void MySlide(float dU, float dV, float dN)
{
	eye.x += dU*u.x + dV*v.x + dN*n.x;
Exemplo n.º 17
0
/*****************************************************
**
**   VedicRasiChart   ---   paintNorth
**
******************************************************/
void VedicRasiChart::paintNorth()
{
	Lang lang;
	wxString s;
	int current, i;

	// used for sign number/symbol display
	const double rtol = xmax / 15.0;

	// used for free space in the middle of the chart (leave free for center string if required)
	const double mtol = xmax / 100.0;

	// 1/4 of the chart
	const double xi = .5 * xr;
	const double yi = .5 * yr;

	// middle square for separation of 2 charts (transit or partner mode)
	const double ri_prop = .4;
	const double xm = ri_prop * xi + ( 1 - ri_prop ) * xr;
	const double ym = ri_prop * yi + ( 1 - ri_prop ) * yr;

	// text separation from chart border
	const double text_border = xr / 30.0;

	// Rasi coordinates in single mode
	const MyRect rasi_rect[12] = {
		MyRect( xcenter - xi, ycenter - yr, xr, yr ),
		MyRect( xcenter - xr, ycenter - yr, xr, yi ),
		MyRect( xcenter - xr, ycenter - yr, xr, yr ),
		MyRect( xcenter - xr, ycenter - yi, xr, yr ),
		MyRect( xcenter - xr, ycenter, xi, yr ),
		MyRect( xcenter - xr, ycenter + yi, xr, yi ),

		MyRect( xcenter - xi, ycenter, xr, yr ),
		MyRect( xcenter, ycenter + yi, xr, yi ),
		MyRect( xcenter, ycenter, xr, yr ),
		MyRect( xcenter, ycenter - yi, xr, yr ),
		MyRect( xcenter + xi, ycenter - yr, xi, yr ),
		MyRect( xcenter, ycenter - yr, xr, yi )
	};

	// Rasi coordinates for 2nd chart (only in double mode)
	const MyRect planet1_rect[12] = {
		MyRect( xcenter - xi, ycenter - ym, xr, xm ),
		MyRect( xcenter - xm, ycenter - ym, xi, ym ),
		MyRect( xcenter - xm, ycenter - yr, xr - xm, yr ),
		MyRect( xcenter - xm, ycenter - yi, xm, yr ),
		MyRect( xcenter - xm, ycenter, xr - xm, yr ),
		MyRect( xcenter - xr, ycenter + yi, xr, ym - yi ),

		MyRect( xcenter - xi, ycenter, xr, ym ),
		MyRect( xcenter + xi / 2, ycenter + yi, xi, ym - yi ),
		MyRect( xcenter + xi, ycenter, xm - xi, yr ),
		MyRect( xcenter, ycenter - yi, xm, yr ),
		MyRect( xcenter + xi, ycenter - ym, xm - xi, ym ),
		MyRect( xcenter + xi / 2, ycenter - ym, xi, ym - xi )
	};

	// Rasi coordinates for 2nd chart (only in double mode)
	const MyRect planet2_rect[12] = {
		MyRect( xcenter - xi, ycenter - yr, xr, yr - ym ),
		MyRect( xcenter - xr, ycenter - yr, xr, yr - ym ),
		MyRect( xcenter - xr, ycenter - yr, xr - xm, yr ),
		MyRect( xcenter - xr, ycenter - yi, xr - xm, yr ),
		MyRect( xcenter - xr, ycenter, xr - xm, yr ),
		MyRect( xcenter - xr, ycenter + ym, xr, yr - ym ),

		MyRect( xcenter - xi, ycenter + ym, xr, yr  - ym ),
		MyRect( xcenter, ycenter + ym, xr, yr - ym ),
		MyRect( xcenter + xm, ycenter, xr - xm, yr ),
		MyRect( xcenter + xm, ycenter - yi, xr - xm, yr ),
		MyRect( xcenter + xm, ycenter - yr, xr - xm, yr ),
		MyRect( xcenter, ycenter - yr, xr, yr - ym )
	};

	// Rectangles for sign names resp. numbers
	const MyRect sign_rect[12] = {
		MyRect( xcenter - rtol, ycenter - rtol, 2 * rtol, rtol ),
		MyRect( xcenter - xi - rtol / 2, ycenter - yi - rtol, rtol, rtol ),
		MyRect( xcenter - xi - rtol, ycenter - yi - rtol / 2, rtol, rtol ),
		MyRect( xcenter - 2 * rtol, ycenter - rtol, 2 * rtol, rtol ),
		MyRect( xcenter - xi - rtol, ycenter + yi - rtol / 2, rtol, rtol ),
		MyRect( xcenter - xi - rtol / 2, ycenter + yi, rtol, rtol ),

		MyRect( xcenter - rtol, ycenter, 2 * rtol, rtol ),
		MyRect( xcenter + xi - rtol / 2, ycenter + yi, rtol, rtol ),
		MyRect( xcenter + xi, ycenter + yi - rtol / 2, rtol, rtol ),
		MyRect( xcenter, ycenter - rtol, 2 * rtol, rtol ),
		MyRect( xcenter + xi, ycenter - yi - rtol / 2, rtol, rtol ),
		MyRect( xcenter + xi - rtol / 2, ycenter - yi - rtol, rtol, rtol )
	};

	// Text alignment for rasis
	const int rasi_alignment[12] = {
		Align::Center,
		Align::Top + Align::HCenter,
		Align::Left + Align::VCenter,
		Align::Center,
		Align::Left + Align::VCenter,
		Align::Bottom + Align::HCenter,

		Align::Center,
		Align::Bottom + Align::HCenter,
		Align::Right + Align::VCenter,
		Align::Center,
		Align::Right + Align::VCenter,
		Align::Top + Align::HCenter
	};

	// polygon coordinates for signs
	const MyPoint rasi_polygons[][12] = {
		{ MyPoint( xcenter-xi, ycenter - yi ), MyPoint( xcenter, ycenter ), MyPoint( xcenter+xi, ycenter - yi ), MyPoint( xcenter, ycenter - yr ) },
		{ MyPoint( xcenter-xr, ycenter - yr ), MyPoint( xcenter, ycenter-yr ), MyPoint( xcenter-xi, ycenter - yi ) },
		{ MyPoint( xcenter-xr, ycenter - yr ), MyPoint( xcenter-xr, ycenter ), MyPoint( xcenter-xi, ycenter - yi ) },
		{ MyPoint( xcenter-xr, ycenter ), MyPoint( xcenter-xi, ycenter+yi ), MyPoint( xcenter, ycenter ), MyPoint( xcenter-xi, ycenter - yi ) },
		{ MyPoint( xcenter-xr, ycenter + yr ), MyPoint( xcenter-xr, ycenter ), MyPoint( xcenter-xi, ycenter + yi ) },
		{ MyPoint( xcenter-xr, ycenter + yr ), MyPoint( xcenter, ycenter+yr ), MyPoint( xcenter-xi, ycenter + yi ) },

		{ MyPoint( xcenter-xi, ycenter+yi ), MyPoint( xcenter, ycenter+yr ), MyPoint( xcenter+xi, ycenter+yi ), MyPoint( xcenter, ycenter ) },
		{ MyPoint( xcenter, ycenter + yr ), MyPoint( xcenter+xr, ycenter+yr ), MyPoint( xcenter+xi, ycenter + yi ) },
		{ MyPoint( xcenter+xr, ycenter + yr ), MyPoint( xcenter+xr, ycenter ), MyPoint( xcenter+xi, ycenter + yi ) },
		{ MyPoint( xcenter, ycenter ), MyPoint( xcenter+xi, ycenter+yi ), MyPoint( xcenter+xr, ycenter ), MyPoint( xcenter+xi, ycenter-yi ) },
		{ MyPoint( xcenter+xr, ycenter - yr ), MyPoint( xcenter+xr, ycenter ), MyPoint( xcenter+xi, ycenter - yi ) },
		{ MyPoint( xcenter, ycenter - yr ), MyPoint( xcenter+xr, ycenter-yr ), MyPoint( xcenter+xi, ycenter - yi ) },
	};

	// rectangle for separation of double charts
	const MyRect transit_rect( xcenter - xm, ycenter - ym, 2 * xm, 2 * ym );

	// draw filled polygons
  GcZodiacalSigns *signs = &vconf->signs;
	if ( signs->needsBgPaint() )
	{
		painter->setTransparentPen();
		for ( i = ARIES; i <= PISCES; i++ )
		{
			painter->setBrush( signs->getBrush(redRasi( getAscendant() + i )));
			painter->drawPolygon( i % 3 ? 3 : 4, (MyPoint*)rasi_polygons[i] );
		}
	}

	paintOuterRectangle();

	painter->setPen( defaultPen );

	// diagonal from egde to egde paint one line or two depending on chart center
	if ( ! ( chartprops->getVedicGraphicStyle().centerInfoType == VGRAPHIC_CHART_CENTER_NOTHING ))
	{
		painter->drawLine( xcenter - xr, ycenter - yr, xcenter - mtol, ycenter - mtol );
		painter->drawLine( xcenter + mtol, ycenter + mtol, xcenter + xr, ycenter + yr );

		painter->drawLine( xcenter - xr, ycenter + yr, xcenter - mtol, ycenter + mtol );
		painter->drawLine( xcenter + mtol , ycenter - mtol, xcenter + xr, ycenter - yr );
	}
	else
	{
		painter->drawLine( xcenter - xr, ycenter - yr, xcenter + xr, ycenter + yr );
		painter->drawLine( xcenter - xr, ycenter + yr, xcenter + xr, ycenter - yr );
	}

	painter->drawLine( xcenter, ycenter + yr, xcenter + xr, ycenter );
	painter->drawLine( xcenter, ycenter + yr, xcenter - xr, ycenter );
	painter->drawLine( xcenter, ycenter - yr, xcenter - xr, ycenter );
	painter->drawLine( xcenter, ycenter - yr, xcenter + xr, ycenter );

	if ( chart_count == 2 ) painter->drawRectangle( transit_rect );

	/*********************************************************
	**  draw number of houses
	*********************************************************/
	if ( ! ( chartprops->getVedicGraphicStyle().northIndianSignDisplayType == VGRAPHIC_NORTH_INDIAN_SYMBOL )) painter->setGraphicFont( textzoom );
	else painter->setSymbolFont( symbolzoom );

	for ( i = ARIES; i <= PISCES; i++ )
	{
		current = redRasi( getAscendant() + i );
		switch( chartprops->getVedicGraphicStyle().northIndianSignDisplayType )
		{
			case VGRAPHIC_NORTH_INDIAN_ASC:
				s.Printf( wxT( "%d" ),  current + 1 );
			break;
			case VGRAPHIC_NORTH_INDIAN_NUMBER:
				s.Printf( wxT( "%d" ),  current + 1 );
			break;
			case VGRAPHIC_NORTH_INDIAN_SHORT:
			{
				s = lang.getSignName( current, TSHORT );
			}
			break;
			default:
				s = lang.getSignSymbolCode( current );
			break;
		}
		painter->drawSimpleText( sign_rect[i], s );

		// leave after ascendant for style == 0
		if ( chartprops->getVedicGraphicStyle().northIndianSignDisplayType == VGRAPHIC_NORTH_INDIAN_ASC ) break;
	}
	painter->setGraphicFont( textzoom );

	/*********************************************************
	**  draw planets
	*********************************************************/
	if ( ! chartprops->isBlank() )
	{

		for ( i = ARIES; i <= PISCES; i++ )
		{
			if ( chart_count == 1 ) drawFieldText( rasi_rect[i], redRasi( i + getAscendant() ), rasi_alignment[i], 0, text_border );
			else
			{
				drawFieldText( planet1_rect[i], redRasi( i + getAscendant() ), rasi_alignment[i], 0, text_border );
				drawFieldText( planet2_rect[i], redRasi( i + getAscendant() ), rasi_alignment[i], 1, text_border );
			}
		}

		paintCenterString();
	}
	painter->setGraphicFont( textzoom );
}
Exemplo n.º 18
0
/*****************************************************
**
**   VedicRasiChart   ---   paintEast
**
******************************************************/
void VedicRasiChart::paintEast()
{
	int i;

	// inner square of chart
	const double xi = xr*0.28;
	const double yi = yr*0.28;

	// middle square for separation of 2 charts
	const double ri_prop = .4;
	const double xm = ri_prop * xi + ( 1 - ri_prop ) * xr;
	const double ym = ri_prop * yi + ( 1 - ri_prop ) * yr;

	const double text_border = xr / 30.0;

	// Rasi coordinates in single mode
	const MyRect rasi_rect[12] = {
		MyRect( xcenter - xi, ycenter - yr, 2 * xi, yr - yi ),
		MyRect( xcenter - xr, ycenter - yr, xr - xi, yr - yi ),
		MyRect( xcenter - xr, ycenter - yr, xr - xi, yr - yi ),
		MyRect( xcenter - xr, ycenter - yi, xr - xi, 2 * yi ),
		MyRect( xcenter - xr, ycenter + yi, xr - xi, yr - yi ),
		MyRect( xcenter - xr, ycenter + yi, xr - xi, yr - yi ),

		MyRect( xcenter - xi, ycenter + yi, 2 * xi, yr - yi ),
		MyRect( xcenter + xi, ycenter + yi, xr - xi, yr - yi ),
		MyRect( xcenter + xi, ycenter + yi, xr - xi, yr - yi ),
		MyRect( xcenter + xi, ycenter - yi, xr - xi, 2 * yi ),
		MyRect( xcenter + xi, ycenter - yr, xr - xi, yr - yi ),
		MyRect( xcenter + xi, ycenter - yr, xr - xi, yr - yi ),
	};

	// Rasi coordinates for 1st chart (only in double mode)
	const MyRect planet1_rect[12] = {
		MyRect( xcenter - xi, ycenter - ym, 2 * xi, yr - ym ),
		MyRect( xcenter - xm, ycenter - ym, xm - xi, ym - yi ),
		MyRect( xcenter - xm, ycenter - ym, xm - xi, ym - yi ),
		MyRect( xcenter - xm, ycenter - yi, xm - xi, 2 * yi ),
		MyRect( xcenter - xm, ycenter + yi, xm - xi, ym - yi ),
		MyRect( xcenter - xm, ycenter + yi, xm - xi, ym - yi ),

		MyRect( xcenter - xi, ycenter + yi, 2 * xi, ym - yi ),
		MyRect( xcenter + xi, ycenter + yi, xm - xi, ym - yi ),
		MyRect( xcenter + xi, ycenter + yi, xm - xi, ym - yi ),
		MyRect( xcenter + xi, ycenter - yi, xm - xi, 2 * yi ),
		MyRect( xcenter + xi, ycenter - ym, xm - xi, ym - yi ),
		MyRect( xcenter + xi, ycenter - ym, xm - xi, ym - yi )
	};

	// Rasi coordinates for 2nd chart (only in double mode)
	const MyRect planet2_rect[12] = {
		MyRect( xcenter - xi, ycenter - yr, 2 * xi, yr - ym ),
		MyRect( xcenter - xm, ycenter - yr, xm - xi, yr - ym ),
		MyRect( xcenter - xr, ycenter - yr, xr - xi, yr - yi ),
		MyRect( xcenter - xr, ycenter - yi, xr - xm, 2 * yi ),
		MyRect( xcenter - xr, ycenter + yi, xr - xm, yr - yi ),
		MyRect( xcenter - xm, ycenter + ym, xr - xm, yr - ym ),

		MyRect( xcenter - xi, ycenter + ym, 2 * xi, yr - ym ),
		MyRect( xcenter + xi, ycenter + ym, xr - xm, yr - ym ),
		MyRect( xcenter + xm, ycenter + yi, xr - xm, yr - yi ),
		MyRect( xcenter + xm, ycenter - yi, xr - xm, 2 * yi ),
		MyRect( xcenter + xm, ycenter - ym, xr - xm, yr - ym ),
		MyRect( xcenter + xi, ycenter - yr, xr - xi, yr - ym ),
	};

	// Text alignment for rasis
	const int rasi_alignment[12] = {
		Align::Center,
		Align::Right + Align::Top,
		Align::Left + Align::Bottom,
		Align::Center,
		Align::Left + Align::Top,
		Align::Right + Align::Bottom,

		Align::Center,
		Align::Left + Align::Bottom,
		Align::Right + Align::Top,
		Align::Center,
		Align::Right + Align::Bottom,
		Align::Left + Align::Top
	};

	// rectangle for separation of double charts
	const MyRect transit_rect( xcenter - xm, ycenter - ym, 2 * xm, 2 * ym );

	painter->setPen( defaultPen );

	// draw filled polygons resp. rectangles if required
  GcZodiacalSigns *signs = &vconf->signs;
	if ( signs->needsBgPaint() )
	{
		painter->setTransparentPen();
		int a = 0;

		painter->setBrush( signs->getBrush( a ));
		painter->drawRectangle( xcenter - xi, ycenter - yr, 2 * xi, yr - yi );

		painter->setBrush( signs->getBrush( a + 1 ));
		MyPoint ptaurus[3] = { MyPoint( xcenter - xr, ycenter - yr ), MyPoint( xcenter - xi, ycenter - yr ), MyPoint( xcenter-xi, ycenter - yi ) };
		painter->drawPolygon( 3, ptaurus );

		painter->setBrush( signs->getBrush( a + 2 ));
		MyPoint pgem[3] = { MyPoint( xcenter - xr, ycenter - yr ), MyPoint( xcenter-xr, ycenter - yi ), MyPoint( xcenter - xi, ycenter - yi ) };
		painter->drawPolygon( 3, pgem );

		painter->setBrush( signs->getBrush( a + 3 ));
		painter->drawRectangle( xcenter - xr, ycenter - yi, xr - xi, 2 * yi );

		painter->setBrush( signs->getBrush( a + 4 ));
		MyPoint pleo[3] = { MyPoint( xcenter - xr, ycenter + yi ), MyPoint( xcenter - xi, ycenter + yi ), MyPoint( xcenter - xr, ycenter + yr ) };
		painter->drawPolygon( 3, pleo );

		painter->setBrush( signs->getBrush( a + 5 ));
		MyPoint pvirgo[3] = { MyPoint( xcenter - xr, ycenter + yr ), MyPoint( xcenter - xi, ycenter + yr ),
			MyPoint( xcenter - xi, ycenter + yi ) };
		painter->drawPolygon( 3, pvirgo );

		painter->setBrush( signs->getBrush( a + 6 ));
		painter->drawRectangle( xcenter - xi, ycenter + yi, 2 * xi, yr - yi );

		painter->setBrush( signs->getBrush( a + 7 ));
		MyPoint pscorp[3] = { MyPoint( xcenter + xi, ycenter + yr ), MyPoint( xcenter + xr, ycenter + yr ),
		                      MyPoint( xcenter + xi, ycenter + yi ) };
		painter->drawPolygon( 3, pscorp );

		painter->setBrush( signs->getBrush( a + 8 ));
		MyPoint p2[3] = { MyPoint( xcenter + xi, ycenter + yi ), MyPoint( xcenter + xr, ycenter + yi ), MyPoint( xcenter + xr, ycenter + yr ) };
		painter->drawPolygon( 3, p2 );

		painter->setBrush( signs->getBrush( a + 9 ));
		painter->drawRectangle( xcenter + xi, ycenter - yi, xr - xi, 2 * yi );

		painter->setBrush( signs->getBrush( a + 10 ));
		MyPoint paqua[3] = { MyPoint( xcenter + xi, ycenter - yi ), MyPoint( xcenter + xr, ycenter - yi ), MyPoint( xcenter + xr, ycenter - yr ) };
		painter->drawPolygon( 3, paqua );

		painter->setBrush( signs->getBrush( a + 11 ));
		MyPoint ppisc[3] = { MyPoint( xcenter + xi, ycenter - yr ), MyPoint( xcenter + xr, ycenter - yr ),
			MyPoint( xcenter + xi, ycenter - yi ) };
		painter->drawPolygon( 3, ppisc );
	}

	paintOuterRectangle();

	painter->setPen( defaultPen );
	painter->drawLine( xcenter - xi, ycenter - yr, xcenter - xi, ycenter + yr );

	painter->drawLine( xcenter + xi, ycenter-yr, xcenter+xi, ycenter+yr );

	painter->drawLine( xcenter - xr, ycenter + yi, xcenter + xr, ycenter + yi );
	painter->drawLine( xcenter - xr, ycenter - yi, xcenter + xr, ycenter - yi );

	painter->drawLine( xcenter - xr, ycenter + yr, xcenter - xi, ycenter + yi );
	painter->drawLine( xcenter - xr, ycenter - yr, xcenter - xi, ycenter - yi );

	painter->drawLine( xcenter + xr, ycenter + yr, xcenter + xi, ycenter + yi );
	painter->drawLine( xcenter + xr, ycenter - yr, xcenter + xi, ycenter - yi );

	if ( chart_count == 2 ) painter->drawRectangle( transit_rect );

	painter->setBrush( defaultBrush );
	if ( ! chartprops->isBlank() )
	{
		for ( i = ARIES; i <= PISCES; i++ )
		{
			if ( chart_count == 1 ) drawFieldText( rasi_rect[i], i, rasi_alignment[i], 0, text_border );
			else
			{
				drawFieldText( planet1_rect[i], i, rasi_alignment[i], 0, text_border );
				drawFieldText( planet2_rect[i], i, rasi_alignment[i], 1, text_border );
			}
		}
		paintCenterString();
	}
	painter->setGraphicFont( textzoom );
}
Exemplo n.º 19
0
bool CaptureManager::SaveTrackImage(wxBitmap &bmp, int start, int end)
{
    if (end == -1) end = frameCount;
	if (!Access(0,0,false, true)->contourArray.size())
	{
		wxLogError(_T("No objects in the first frame. Detect/draw boundaries in the first frame and apply tracking first."));
		return false;
	}
	wxRealPoint scale(6, 6);
	bmp.Create(scale.x*size.width, scale.y*size.height);
	wxMemoryDC dc(bmp);
	dc.SetBackground(*wxWHITE_BRUSH);
	dc.Clear();

	for (int c=0; c<Access(0, 0, false, true)->contourArray.size(); c++)
	{
        std::vector<CvPoint> traj = GetTrajectory(c);
        std::vector< std::vector<double> > ratios;
        CvPoint lastTraj = traj[start];
        float maxRatio = 0;
        float minRatio = 0;
		for (int i=start+1; i<end && Access(i, 0, false, true)->contourArray.size() > c; i++)
        {
            CvSeq* oseq = Access(i-1, 0, false, true)->contourArray[c];
            CvSeq* seq = Access(i, 0, false, true)->contourArray[c];
            ratios.push_back(std::vector<double>());
            for (int j=0; j<oseq->total; j++)
            {
                CvPoint *lastLoc = (CvPoint*) cvGetSeqElem(oseq, j);
                if(seq->total <= j)
					continue;
                CvPoint *p = (CvPoint*) cvGetSeqElem(seq, j);
                float ptx = p->x - lastLoc->x;
                float pty = p->y - lastLoc->y;
                float trajx = traj[i].x - lastTraj.x;
                float trajy = traj[i].y - lastTraj.y;
                float ratio = (ptx*trajx + pty*trajy)/(trajx*trajx + trajy*trajy);
                if (maxRatio < ratio)
                    maxRatio = ratio;
                if (minRatio > ratio)
                    minRatio = ratio;
                ratios[i-1-start].push_back(ratio);
            }
            lastTraj = traj[i];
        }

		CvSeq* oseq = Access(start, 0, false, true)->contourArray[c];
		MyCanvas::DrawContour_static(&dc, oseq, wxPoint(0,0), scale);
		for (int i=0; i<oseq->total; i++)
		{
			CvPoint *lastLoc = (CvPoint*) cvGetSeqElem(oseq, i);
			dc.SetPen(wxPen(wxColour(Preferences::GetColorContourPointColor())));
			dc.SetBrush(*wxTRANSPARENT_BRUSH);
			for (int j=start+1; j<end; j++)
			{
				if(Access(j,0,false, true)->contourArray.size() <= c || Access(j,0,false, true)->contourArray[c]->total <= i)
					continue;
				CvPoint *p = (CvPoint*) cvGetSeqElem(Access(j, 0, false, true)->contourArray[c], i);
				dc.DrawLine(scale.x*lastLoc->x, scale.y*lastLoc->y, scale.x*p->x, scale.y*p->y);
				lastLoc = p;
			}
			//dc.DrawCircle(MyPoint((CvPoint*)cvGetSeqElem(Access(start, 0, false, true)->contourArray[c],i))*scale, Preferences::GetColorContourBorderWidth());
			for (int j=start+1; j<end; j++)
			{
			    wxColor pointColor(*wxLIGHT_GREY);
                if (ratios[j-1-start][i] > 0)
                    pointColor = wxColor(128 + 127*ratios[j-1-start][i]/maxRatio, 128 - 128*ratios[j-1-start][i]/maxRatio, 128 - 128*ratios[j-1-start][i]/maxRatio);
                else
                    pointColor = wxColor(128 - 128*ratios[j-1-start][i]/minRatio, 128 - 128*ratios[j-1-start][i]/minRatio, 128 + 127*ratios[j-1-start][i]/minRatio);
                dc.SetPen(wxPen(pointColor));
                dc.SetBrush(pointColor);
				if(Access(j, 0, false, true)->contourArray.size() <= c || Access(j, 0, false, true)->contourArray[c]->total <= i)
					continue;
				CvPoint *p = (CvPoint*) cvGetSeqElem(Access(j, 0, false, true)->contourArray[c], i);
				dc.DrawCircle(MyPoint(*p)*scale, Preferences::GetColorContourBorderWidth()*2);
			}
		}
		lastTraj = traj[start];
		dc.SetBrush(*wxTRANSPARENT_BRUSH);
		for (int i=start+1; i<end/*traj.size()*/; i++)
		{
			if(traj[i].x<0)
				continue;
			if (i>0)
			{
				dc.SetPen(wxPen(wxColour(Preferences::GetColorContourBorderColor()), Preferences::GetColorContourBorderWidth()));
				dc.DrawLine(scale.x*lastTraj.x,scale.y*lastTraj.y, scale.x*traj[i].x,scale.y*traj[i].y);
			}
			lastTraj = traj[i];
		}
		if(c < Access(end-1,0,false, true)->contourArray.size())
			MyCanvas::DrawContour_static(&dc, Access(end-1,0,false, true)->contourArray[c], wxPoint(0,0), scale, true, wxRED);
	}
	return true;
}