예제 #1
0
void Draw_Building(way* w, char* role, RGBA* color, char* type)
{
	Sint16 *vx, *vy;
	RGBA rgba;
	node_t* node = NULL;
	double longitude, latitude, minlat, maxlat, minlon, maxlon;
	int i, j, k, index, compteur, value_tag;
	static int policy = 0;
	
	maxlat = pBound->maxlat;
	minlat = pBound->minlat;
	maxlon = pBound->maxlon;
	minlon = pBound->minlon;
	
	vx = malloc(w->size_ref * sizeof(*vx));
	vy = malloc(w->size_ref * sizeof(*vy));
	compteur = 0;

	for(i = 0; i < w->size_ref; i++)
	{
		index = search_node_dicho(w->ref[i]);
	
		if(index == FAILURE)
			continue;
		
		node = pRoot->arrayNodes[index];
		
		longitude = node->longitude;
		latitude = node->latitude;

		vx[i] = (Sint16)(long_to_pix(longitude) * pMap->width * pMap->zoom);
		vy[i] = (Sint16)(lat_to_pix(latitude) * pMap->height * pMap->zoom);

		compteur++;
	}
	
	if(type != NULL && !strcmp(type, "barrier"))
	{
		for(i = 0; i < compteur - 1; i++)
     	 	aalineRGBA(pRenderer, vx[i], vy[i], vx[i+1], vy[i+1], color->r, color->g, color->b, color->a);
	}
	else
	{
		filledPolygonRGBA(pRenderer, vx, vy, compteur, color->r, color->g, color->b, color->a);
	
		if(role == NULL)
		{
			rgba = colorConverter(BARRIER_COLOR);
			for(i = 0; i < compteur - 1; i++)
		 	 	aalineRGBA(pRenderer, vx[i], vy[i], vx[i+1], vy[i+1], rgba.r, rgba.g, rgba.b, rgba.a);
		}
    }	 	
	free(vx);
	free(vy);
}
예제 #2
0
void Draw_Highway(way* w, char* role, RGBA* color, int length, char* type)
{
	Sint16 *vx, *vy;
	Sint16 mx1, my1, mx2, my2;
	RGBA rgba;
	node_t* node = NULL;
	double longitude, latitude, minlat, maxlat, minlon, maxlon, offset = 0;
	double alpha, num, distance, decimal_part;
	int i, j, index, compteur = 0;
	bool visible;
	
	maxlat = pBound->maxlat;
	minlat = pBound->minlat;
	maxlon = pBound->maxlon;
	minlon = pBound->minlon;
	
	vx = malloc(w->size_ref * sizeof(*vx));
	vy = malloc(w->size_ref * sizeof(*vy));
	
	for(i = 0; i < w->size_ref; i++)
	{
		index = search_node_dicho(w->ref[i]);
	
		if(index == FAILURE)
			continue;
		
		node = pRoot->arrayNodes[index];
		
		longitude = node->longitude;
		latitude = node->latitude;

		vx[i] = (Sint16)(long_to_pix(longitude) * pMap->width * pMap->zoom);
		vy[i] = (Sint16)(lat_to_pix(latitude) * pMap->height * pMap->zoom);

		compteur++;
	}
	
	if(type != NULL && !strcmp(type, "pedestrian"))
	{
		rgba = colorConverter(PEDESTRIAN_FILL_COLOR);
		filledPolygonRGBA(pRenderer, vx, vy, compteur, rgba.r, rgba.g, rgba.b, rgba.a);
		//rgba = colorConverter(PEDESTRIAN_CONTOUR_COLOR);
		for(i = 0; i < compteur - 1; i++)
			thickLineRGBA(pRenderer, vx[i], vy[i], vx[i+1], vy[i+1], length, rgba.r, rgba.g, rgba.b, rgba.a);
	}
	else
		for(i = 0; i < compteur - 1; i++)
			thickLineRGBA(pRenderer, vx[i], vy[i], vx[i + 1], vy[i + 1], length, color->r, color->g, color->b, color->a);
	
	free(vx);
	free(vy);
}
예제 #3
0
void Draw_Leisure(way* w, char* role, RGBA* color, char* type)
{
	Sint16 *vx, *vy;
	RGBA rgba;
	node_t* node = NULL;
	double longitude, latitude, minlat, maxlat, minlon, maxlon;
	int i, index, compteur = 0;
	
	maxlat = pBound->maxlat;
	minlat = pBound->minlat;
	maxlon = pBound->maxlon;
	minlon = pBound->minlon;
	
	vx = malloc(w->size_ref * sizeof(*vx));
	vy = malloc(w->size_ref * sizeof(*vy));

	for(i = 0; i < w->size_ref; i++)
	{
		index = search_node_dicho(w->ref[i]);
	
		if(index == FAILURE)
			continue;
		
		node = pRoot->arrayNodes[index];
		
		longitude = node->longitude;
		latitude = node->latitude;

		vx[i] = (Sint16)(long_to_pix(longitude) * pMap->width * pMap->zoom);
		vy[i] = (Sint16)(lat_to_pix(latitude) * pMap->height * pMap->zoom);

		compteur++;
	}

	if(!strcmp(type, "garden"))
	{
		rgba = colorConverter(WHITE);
		for(i = 0; i < compteur - 1; i++)
			thickLineRGBA (pRenderer, vx[i], vy[i], vx[i+1], vy[i+1], 2, rgba.r, rgba.g, rgba.b, rgba.a);
	}
	else
		filledPolygonRGBA(pRenderer, vx, vy, compteur, color->r, color->g, color->b, color->a);
		
	free(vx);
	free(vy);
}
예제 #4
0
wxPGProperty*
WXEffectEditDialog::CreateProperty(const Ogre::ParameterDef& propertyDef, Ogre::StringInterface *basic)
{
	wxPGProperty* property = NULL;
	wxString name = propertyDef.name.c_str();
	Ogre::String value = basic->getParameter(name.c_str());
	Ogre::ParameterType paraType = propertyDef.paramType;

	switch ( paraType )
	{
	case Ogre::PT_COLOURVALUE:
		property = wxFairyColourProperty(name, name, colorConverter(value));
		break;

	case Ogre::PT_STRING:
		{
			wxPGConstants* constants = PopulateConstants(propertyDef.name);
			if (constants)
			{
				// 创建出combobox
				property = wxEnumProperty(name, name, *constants);
				// 设置成当前这个参数的值
				property->SetValueFromString(value.c_str(),0);
			}
			
			break;
		}

	case Ogre::PT_REAL:
		{
			property = wxFloatProperty(name, name, Ogre::StringConverter::parseReal(value));

			break;
		}

	default:
		property = wxStringProperty(name, name, value.c_str());
		break;
	}

	assert (property);
	
	return property;
}
wxPGProperty*
FairySkillEditDialog::CreateProperty(const Ogre::ParameterDef& propertyDef, Ogre::String &value)
{
	wxPGProperty* property = NULL;
	wxString name = propertyDef.name.c_str();
	Ogre::ParameterType paraType = propertyDef.paramType;

	switch ( paraType )
	{
	case Ogre::PT_COLOURVALUE:
		property = wxFairyColourProperty(name, name, colorConverter(value));
		break;

	case Ogre::PT_STRING:
		{
			if (name == "HitTime")
			{
				Ogre::String newValue("");

				for (unsigned short i=0; i<mSkill->getNumHitTimes(); ++i)
				{
					float time = mSkill->getHitTime(i);

					newValue += Ogre::StringConverter::toString( (time * mDObject->getCurrentAnimationLength() * mFramePerSecond) );
					newValue += " ";
				}
				property = wxStringProperty(name, name, newValue.c_str());
			}
			else if (name == "BreakTime")
			{
				Ogre::String newValue("");

				for (unsigned short i=0; i<mSkill->getNumBreakTimes(); ++i)
				{
					float time = mSkill->getBreakTime(i);

					newValue += Ogre::StringConverter::toString( (time * mDObject->getCurrentAnimationLength() * mFramePerSecond) );
					newValue += " ";
				}
				property = wxStringProperty(name, name, newValue.c_str());
			}
            else if (name == "ShakeTime")
            {
                Ogre::String newValue("");

                for (unsigned short i=0; i<mSkill->getNumShakeTimes(); ++i)
                {
                    float time = mSkill->getShakeTime(i);

                    newValue += Ogre::StringConverter::toString( (time * mDObject->getCurrentAnimationLength() * mFramePerSecond) );
                    newValue += " ";
                }
                property = wxStringProperty(name, name, newValue.c_str());
            }
			else
			{
				wxPGConstants* constants = PopulateConstants(propertyDef.name);
				if (constants)
				{
					// 创建出combobox
					property = wxEnumProperty(name, name, *constants);
					// 设置成当前这个参数的值
					property->SetValueFromString(value.c_str());
				}
				else
				{				
					property = wxStringProperty(name, name, value.c_str());
				}
			}			

			break;
		}

	case Ogre::PT_REAL:
		{
			if (name == "AttachTime")
			{
				float inputValue = Ogre::StringConverter::parseReal(value);

				if (inputValue >= 0.0f && inputValue <= 1.0f)
					value = Ogre::StringConverter::toString( (inputValue * mDObject->getCurrentAnimationLength() * mFramePerSecond) );
			}

			property = wxFloatProperty(name, name, Ogre::StringConverter::parseReal(value));

			break;
		}

	case Ogre::PT_BOOL:
		{
			size_t id = reinterpret_cast<size_t>(&name);
			wxPGConstants* constants = wxPropertyGrid::GetConstantsArray(id);

			if (!constants)
			{
				constants = wxPropertyGrid::CreateConstantsArray(id);		

				constants->Add("true");
				constants->Add("false");

				registerConstants(constants);
			}

			if (constants)
			{
				// 创建出combobox
				property = wxEnumProperty(name, name, *constants);
				// 设置成当前这个参数的值
				property->SetValueFromString(value.c_str());
			}
			break;
		}

	default:
		property = wxStringProperty(name, name, value.c_str());
		break;
	}

	assert (property);

	return property;
}
예제 #6
0
void CDataView::ProcessAs2D()
{
	size_t dataBytes = m_data.size();
	const char* pData = &m_data[0];
	
	const DataSetting2D& setting = dynamic_cast<const DataSetting2D&>(*m_pDataSetting);
	int width = EvalFormula(setting.widthFormula);
	if (width <= 0)
		return;
	int height = EvalFormula(setting.heightFormula);
	if (height <= 0)
		return;
	
	int pixelStride;
	size_t colorFormatPixelSize = GetByteSize(setting.colorFormat);
	if (setting.bUsePixelStride) {
		pixelStride = EvalFormula(setting.pixelStrideFormula);
		if (pixelStride <= 0 || pixelStride < colorFormatPixelSize) {
			return;
		}
	}else {
		pixelStride = colorFormatPixelSize;
	}
	
	size_t lineBytes = 0;
	if (setting.colorFormat == ColorFormatType_1) {
		lineBytes = width / 8 + ((width % 8) ? 1 : 0);
	}else {
		lineBytes = width * pixelStride;
	}

	int lineStride = setting.bUseLineStride ? EvalFormula(setting.lineStrideFormula) : lineBytes;
	if (lineStride == 0)
		return;
	
	if (abs(lineStride) < lineBytes)
		return;
	if (abs(lineStride)*height != dataBytes)
		return;
	
	const char* pFirstLine = NULL;
	switch (setting.addressedLine) {
	case DataSetting2D::AddressedLine_Last:
	case DataSetting2D::AddressedLine_First:
		if (lineStride < 0) {
			pFirstLine = pData + -lineStride * (int)(height - 1);
		}else {
			pFirstLine = pData;
		}
		break;
	}
	if (m_pImage) {
		if (m_pImage->GetWidth() < width || m_pImage->GetHeight() < height) {
			DeleteObject(m_hBMP);
			delete m_pImage;
			m_pImage = 0;
		}
	}
	if (!m_pImage) {
		m_hBMP = CreateDIB32(width, -height, m_bmi, m_pBits);
		m_pImage = gl::BuildBuffer2DFromBMP(m_bmi.bmiHeader, m_pBits);
		m_memDC.SelectBitmap(m_hBMP);
	}
	m_imgWidth = width;
	m_imgHeight = height;
	gl::Buffer2D<ColorB8G8R8A8>& img = *(gl::Buffer2D<ColorB8G8R8A8>*)m_pImage;
	
	if (setting.colorFormat != ColorFormatType_1 && IsSingleComponent(setting.colorFormat)) {
		gl::ColorConverterMinMax<ColorB8G8R8A8> colorConverter(EvalFormula(setting.minimumFormula), EvalFormula(setting.maximumFormula));
		switch (setting.colorFormat) {
		case ColorFormatType_F32:
			gl::BitBlockTransfer(gl::Buffer2D<float>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
			break;
		case ColorFormatType_F64:
			gl::BitBlockTransfer(gl::Buffer2D<double>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
			break;
		case ColorFormatType_U8:
			gl::BitBlockTransfer(gl::Buffer2D<uint8_t>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
			break;
		case ColorFormatType_U16:
			gl::BitBlockTransfer(gl::Buffer2D<uint16_t>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
			break;
		case ColorFormatType_U32:
			gl::BitBlockTransfer(gl::Buffer2D<uint32_t>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
			break;
		case ColorFormatType_S8:
			gl::BitBlockTransfer(gl::Buffer2D<int8_t>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
			break;
		case ColorFormatType_S16:
			gl::BitBlockTransfer(gl::Buffer2D<int16_t>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
			break;
		case ColorFormatType_S32:
			gl::BitBlockTransfer(gl::Buffer2D<int32_t>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
			break;
		}
	}else {
		gl::ColorConverter<ColorB8G8R8A8> colorConverter;
		switch (setting.colorFormat) {
		case ColorFormatType_1:
			gl::BitBlockTransfer(gl::Buffer2D<bool>(width, height, lineStride, (void*)pFirstLine), img, 0,0,0,0,width,height, colorConverter);
			break;
		case ColorFormatType_B5G6R5:
			gl::BitBlockTransfer(gl::Buffer2D<ColorB5G6R5>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
			break;
		case ColorFormatType_B8G8R8:
			gl::BitBlockTransfer(gl::Buffer2D<ColorB8G8R8>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
			break;
		case ColorFormatType_B8G8R8A8:
			gl::BitBlockTransfer(gl::Buffer2D<ColorB8G8R8A8>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
			break;
		}
	}

}