示例#1
0
void wxSVGCanvasCairo::SetClipPath(wxSVGElement* clipPathElem, wxSVGMatrix matrix) {
	SetMatrix(m_cr, matrix);
	wxSVGElement* elem = (wxSVGElement*) (clipPathElem->GetFirstChild());
	while (elem != NULL) {
		elem->SetOwnerSVGElement(clipPathElem->GetOwnerSVGElement());
		elem->SetViewportElement(clipPathElem->GetViewportElement());
		wxSVGDocument* doc = (wxSVGDocument*) elem->GetOwnerDocument();
		wxSVGCanvasItem* canvasItem = NULL;
		switch (elem->GetDtd()) {
		case wxSVG_G_ELEMENT: {
			wxSVGGElement* gElement = (wxSVGGElement*) elem;
			if (gElement->GetVisibility() == wxCSS_VALUE_HIDDEN)
				break;
			wxSVGMatrix gMatrix(matrix);
			gElement->UpdateMatrix(gMatrix);
			SetClipPath(elem, gMatrix);
			SetMatrix(m_cr, matrix);
			break;
		}
		case wxSVG_LINE_ELEMENT:
			canvasItem = doc->GetCanvas()->CreateItem((wxSVGLineElement*) elem);
			break;
		case wxSVG_POLYLINE_ELEMENT:
			canvasItem = doc->GetCanvas()->CreateItem((wxSVGPolylineElement*) elem);
			break;
		case wxSVG_POLYGON_ELEMENT:
			canvasItem = doc->GetCanvas()->CreateItem((wxSVGPolygonElement*) elem);
			break;
		case wxSVG_RECT_ELEMENT:
			canvasItem = doc->GetCanvas()->CreateItem((wxSVGRectElement*) elem);
			break;
		case wxSVG_CIRCLE_ELEMENT:
			canvasItem = doc->GetCanvas()->CreateItem((wxSVGCircleElement*) elem);
			break;
		case wxSVG_ELLIPSE_ELEMENT: {
			canvasItem = doc->GetCanvas()->CreateItem((wxSVGEllipseElement*) elem);
			break;
		}
		case wxSVG_PATH_ELEMENT:
			canvasItem = doc->GetCanvas()->CreateItem((wxSVGPathElement*) elem);
			break;
		default:
			break;
		}
		if (canvasItem != NULL) {
			cairo_path_t* path =
					((wxSVGCanvasPathCairo*) canvasItem)->GetPath();
			cairo_append_path(m_cr, path);
			cairo_clip(m_cr);
			//cairo_path_destroy(path);
			delete canvasItem;
		}
		elem = (wxSVGElement*) elem->GetNextSibling();
	}
}
void Shifted_HGVolatilityFunction::print(const std::string& filename) const  // OK: test passed.
{
	//std::string fileName = "HGVolatilityFunction.csv";
	std::string path = LMMPATH::get_output_path() + filename;

	std::vector<PrintElement_PTR> elements_print;

	//! h,g,hgMatrix
	typedef boost::numeric::ublas::matrix<double> matrix;
	size_t horizon_ = this->get_LMMTenorStructure()->get_horizon();
	matrix hMatrix(horizon_+1, horizon_+1);
	matrix gMatrix(horizon_+1, horizon_+1);
	matrix hgMatrix(horizon_+1, horizon_+1);

	for(size_t indexLibor = 1; indexLibor<=horizon_; ++indexLibor)
	{
		for(size_t indexT = 1; indexT<=indexLibor; ++indexT)
		{
			hMatrix(indexLibor,indexT)  = pShifted_HGVolatilityParam_->h(indexLibor,indexT);
			gMatrix(indexLibor,indexT)  = pShifted_HGVolatilityParam_->g(indexLibor,indexT);
			hgMatrix(indexLibor,indexT) = get_varSigma_timeIndexVersion(indexLibor,indexT);
		}
	}

	//seems a problem of shared ptr polymorphisms ... 
	//PrintElement_PTR tenorType_print    = PrintElement_PTR(new ScalarPrintElement<std::string>("tenorType", tenorType_));
	//PrintElement_PTR horizon_print      = PrintElement_PTR(new ScalarPrintElement<LMM::Index>("horizon", horizon_));
	PrintElement_PTR hMatrix_print   = PrintElement_PTR(new MatrixPrintElement<matrix>("hMatrix",  hMatrix));
	PrintElement_PTR gMatrix_print   = PrintElement_PTR(new MatrixPrintElement<matrix>("gMatrix",  gMatrix));
	PrintElement_PTR hgMatrix_print  = PrintElement_PTR(new MatrixPrintElement<matrix>("hgMatrix", hgMatrix));


	//elements_print.push_back(tenorType_print);
	elements_print.push_back(hMatrix_print);
	elements_print.push_back(gMatrix_print);
	elements_print.push_back(hgMatrix_print);

	Printer printer(path, elements_print);
	printer.print();
}
示例#3
0
////////////////////////////////////////////////////////////
/// Draw Hud
////////////////////////////////////////////////////////////
void MainClient::_drawHud(void)
{
	glm::mat4 save_matrix = gMatrix()[2];
	gMatrix()[2] = glm::mat4(1.0f);

	//Draw actual bars for values

	float length;
	Sprite *bar = &gs.hud.Object[GameSprites::HUD::CIRCLEBAR];
	glm::vec4 color = glm::vec4(1.0f, 0.3f, 0.3f, 1.0f);
	if(mPlayer->pWeapon.pInfo.Clip){
		length = float(mPlayer->pWeapon.pInfo.Clip)/mPlayer->pWeapon.pInfo.Ammo * 100.0f;
	}
	else {
		length = (mPlayer->pTime.Diff(mPlayer->pTime.Reload.Stamp))/mPlayer->pWeapon.pInfo.Reload * 100.0f;
	}

	//Ammo bar
	bar->pInfo.scale = glm::vec3(length/3, 1.0f, 1.0f);
	bar->pInfo.angle.z = 0.0f;
	bar->pInfo.color = glm::vec4(1.0f, 0.3f, 1.0f, 0.5f);
	bar->pInfo.pos = glm::vec3(-50.0f-length/3, -288.0f, 0.0f);
	bar->Draw();

	//Health bar
	mPlayer->pHealth = (mPlayer->pHealth < 0.0f) ? 0.0f : mPlayer->pHealth;
	bar->pInfo.scale.x = mPlayer->pHealth/3;
	bar->pInfo.color = glm::vec4(1.0f, 0.3f, 0.3f, 0.5f);
	bar->pInfo.pos = glm::vec3(-50.0f-mPlayer->pHealth/3, -263.0f, 0.0f);
	bar->Draw();

	gs.hud.Object[GameSprites::HUD::FRAME].pInfo.pos.y = -250.0f;
	gs.hud.Object[GameSprites::HUD::FRAME].Draw();
	glm::vec3 hscale = glm::vec3(mPlayer->pHealth/100.0f,mPlayer->pHealth/100.0f,mPlayer->pHealth/100.0f);
	gs.hud.Object[GameSprites::HUD::HEALTH].pInfo.scale = hscale;
	gs.hud.Object[GameSprites::HUD::HEALTH].Draw();

	gs.hud.Object[GameSprites::HUD::FRAME].pInfo.pos.y = -275.0f;
	gs.hud.Object[GameSprites::HUD::FRAME].Draw();
	gs.hud.Object[GameSprites::HUD::AMMO].Draw();

	//Jets, spawn circle bars

	bar->pInfo.pos = glm::vec3(80.0f, -265.0f, 0.0f);
	bar->pInfo.scale = glm::vec3(1.2f, 1.2f, 1.2f);
	bar->pInfo.angle.z = 0.0f;
	bar->pInfo.color = glm::vec4(0.2, 1.0f, 0.5f, 0.7f);
	if(mPlayer->pJetCounter < (75))
		bar->pInfo.color = glm::vec4(0.0f, 1.0f, 1.0f, 0.7f);
	if(mPlayer->pJetCounter < 40)
		bar->pInfo.color = glm::vec4(1.0f, 0.3f, 0.4f, 0.7f);

	float step = 360.0f / 100.0f; // replace 100.0f with the map default

	//We manualy draw the circle bar here to save fps
	bar->pInfo.shdProgram->Use();

	glm::mat4 barview(1.0f);
	glm::mat4 barscale = glm::translate(barview, bar->pInfo.pos);

	glUniform4fv(bar->pInfo.shdColor_loc, 1, &bar->pInfo.color.r);

	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, bar->pInfo.txrId);

	glBindVertexArray(bar->pInfo.vaoVertex);

	//Draw the bars
	for(int i=0;i<mPlayer->pJetCounter;i++){
		bar->pInfo.angle.z+=step;
		barview = glm::rotate(barscale, bar->pInfo.angle.z, glm::vec3(0,0,1));
		barview = glm::scale(barview, bar->pInfo.scale * glm::vec3(bar->pInfo.w, bar->pInfo.h,1));
		bar->pInfo.shdProgram->ViewMat(glm::value_ptr(barview));

		glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
	}

	glBindVertexArray(0);

	glBindTexture(GL_TEXTURE_2D, 0);
	glUseProgram(0);

	//On switch weapon
	if(wepswitchtimer > 0.0f){
		Sprite *weapon;
		glm::vec3 scale;
		if(mPlayer->pWeaponID > 0){
			weapon = &gs.Weapon[mPlayer->pWeaponID-1];
			scale = weapon->pInfo.scale;
			weapon->pInfo.pos = glm::vec3(-80,100,0);
			weapon->pInfo.scale = glm::vec3(3,3,3);
			weapon->pInfo.color.a = wepswitchtimer/5.0f;
			weapon->pInfo.angle = glm::vec3(0,0,0);
			weapon->Draw();

			weapon->pInfo.color.a = 1.0f;
			weapon->pInfo.scale = scale;
		}
		weapon = &gs.Weapon[mPlayer->pWeaponID];
		scale = weapon->pInfo.scale;
		weapon->pInfo.pos = glm::vec3(0,100,0);
		weapon->pInfo.scale = glm::vec3(4,4,4);
		weapon->pInfo.color.a = wepswitchtimer;
		weapon->pInfo.angle = glm::vec3(0,0,0);
		weapon->Draw();

		weapon->pInfo.color.a = 1.0f;
		weapon->pInfo.scale = scale;
	}

	gMatrix()[2] = save_matrix;
}