当前位置: 首页>>代码示例>>C++>>正文


C++ FilePath::ReplaceFilename方法代码示例

本文整理汇总了C++中FilePath::ReplaceFilename方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePath::ReplaceFilename方法的具体用法?C++ FilePath::ReplaceFilename怎么用?C++ FilePath::ReplaceFilename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FilePath的用法示例。


在下文中一共展示了FilePath::ReplaceFilename方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LoadCubemap

void CubemapEditorDialog::LoadCubemap(const QString& path)
{
	FilePath filePath(path.toStdString());
	TextureDescriptor* texDescriptor = TextureDescriptor::CreateFromFile(filePath);
	
	if(NULL != texDescriptor &&
	   texDescriptor->IsCubeMap())
	{
		String fileNameWithoutExtension = filePath.GetFilename();
		String extension = filePath.GetExtension();
		fileNameWithoutExtension.replace(fileNameWithoutExtension.find(extension), extension.size(), "");

		bool cubemapLoadResult = true;
		for(int i = 0; i < CubemapUtils::GetMaxFaces(); ++i)
		{
			if(texDescriptor->dataSettings.faceDescription & (1 << CubemapUtils::MapUIToFrameworkFace(i)))
			{
				FilePath faceFilePath = filePath;
				faceFilePath.ReplaceFilename(fileNameWithoutExtension +
											 CubemapUtils::GetFaceNameSuffix(CubemapUtils::MapUIToFrameworkFace(i)) + "." +
											 CubemapUtils::GetDefaultFaceExtension());

				bool faceLoadResult = LoadImageTo(faceFilePath.GetAbsolutePathname(), i, true);
				cubemapLoadResult = cubemapLoadResult && faceLoadResult;
			}
		}
		
		if(!cubemapLoadResult)
		{
			ShowErrorDialog("This cubemap texture seems to be damaged.\nPlease repair it by setting image(s) to empty face(s) and save to disk.");
		}
	}
	else
	{
		if(NULL == texDescriptor)
		{
			ShowErrorDialog("Failed to load cubemap texture " + path.toStdString());
		}
		else
		{
			ShowErrorDialog("Failed to load cubemap texture " + path.toStdString() + ". Seems this is not a cubemap texture.");
		}
	}

	SafeDelete(texDescriptor);
}
开发者ID:galek,项目名称:dava.framework,代码行数:46,代码来源:CubemapEditorDialog.cpp

示例2: ReloadTextures

void CubeMapTextureBrowser::ReloadTextures(const DAVA::String& rootPath)
{	
	cubeListItemDelegate.ClearCache();
	ui->listTextures->clear();
	ui->listTextures->setVisible(false);
	ui->loadingWidget->setVisible(true);
	
	
	this->paintEvent(NULL);
	ui->loadingWidget->update();
	QApplication::processEvents();
	QApplication::flush();
	
	this->setUpdatesEnabled(false);

	QDir dir(rootPath.c_str());
	QStringList filesList = dir.entryList(QStringList("*.tex"));
	size_t cubemapTextures = 0;
	
	if(filesList.size() > 0)
	{
		DAVA::Vector<CubeListItemDelegate::ListItemInfo> cubemapList;
		FilePath fp = rootPath;
		for(int i = 0; i < filesList.size(); ++i)
		{
			QString str = filesList.at(i);
			fp.ReplaceFilename(str.toStdString());
			
			DAVA::TextureDescriptor* texDesc = DAVA::TextureDescriptor::CreateFromFile(fp);
			if(texDesc && texDesc->IsCubeMap())
			{
				CubeListItemDelegate::ListItemInfo itemInfo;
				itemInfo.path = fp;
				itemInfo.valid = ValidateTextureAndFillThumbnails(fp, itemInfo.icons, itemInfo.actualSize);
				
				if(itemInfo.valid)
				{
					cubemapList.push_back(itemInfo);
				}
				else
				{
					//non-valid items should be always at the beginning of the list
					cubemapList.insert(cubemapList.begin(), itemInfo);
				}
			}

			SafeDelete(texDesc);
		}
		
		cubeListItemDelegate.UpdateCache(cubemapList);
		
		for(size_t i = 0; i < cubemapList.size(); ++i)
		{
			CubeListItemDelegate::ListItemInfo& itemInfo = cubemapList[i];
			
			QListWidgetItem* listItem = new QListWidgetItem();
			listItem->setData(Qt::CheckStateRole, false);
			listItem->setData(CUBELIST_DELEGATE_ITEMFULLPATH, itemInfo.path.GetAbsolutePathname().c_str());
			listItem->setData(CUBELIST_DELEGATE_ITEMFILENAME, itemInfo.path.GetFilename().c_str());
			ui->listTextures->addItem(listItem);
		}
		
		cubemapTextures = cubemapList.size();
		ui->listTextures->setCurrentItem(ui->listTextures->item(0));
	}
	
	this->setUpdatesEnabled(true);
	
	ui->listTextures->setVisible(cubemapTextures > 0);
	ui->loadingWidget->setVisible(false);
	
	UpdateCheckedState();
}
开发者ID:galek,项目名称:dava.framework,代码行数:73,代码来源:CubeMapTextureBrowser.cpp

示例3: SaveCubemap

void CubemapEditorDialog::SaveCubemap(const QString& path)
{
	FilePath filePath(path.toStdString());
	DAVA::uint8 faceMask = GetFaceMask();
		
	//copy file to the location where .tex will be put. Add suffixes to file names to distinguish faces
	String fileNameWithoutExtension = filePath.GetFilename();
	String extension = filePath.GetExtension();
	fileNameWithoutExtension.replace(fileNameWithoutExtension.find(extension), extension.size(), "");
	for(int i = 0 ; i < CubemapUtils::GetMaxFaces(); ++i)
	{
		if(!facePath[i].isNull())
		{
			FilePath faceFilePath = filePath;
			faceFilePath.ReplaceFilename(fileNameWithoutExtension +
										 CubemapUtils::GetFaceNameSuffix(CubemapUtils::MapUIToFrameworkFace(i)) + "." +
										 CubemapUtils::GetDefaultFaceExtension());

			DAVA::String targetFullPath = faceFilePath.GetAbsolutePathname().c_str();
			if(facePath[i] != targetFullPath.c_str())
			{
				if(QFile::exists(targetFullPath.c_str()))
				{
					int answer = ShowQuestion("File overwrite",
											  "File " + targetFullPath + " already exist. Do you want to overwrite it with " + facePath[i].toStdString(),
											  MB_FLAG_YES | MB_FLAG_NO, MB_FLAG_NO);
					
					if(MB_FLAG_YES == answer)
					{
						bool removeResult = QFile::remove(targetFullPath.c_str());
						
						if(!removeResult)
						{
							ShowErrorDialog("Failed to copy texture " + facePath[i].toStdString() + " to " + targetFullPath.c_str());
							return;
						}

					}
					else
					{
						continue;
					}
				}
				
				bool copyResult = QFile::copy(facePath[i], targetFullPath.c_str());
				
				if(!copyResult)
				{
					ShowErrorDialog("Failed to copy texture " + facePath[i].toStdString() + " to " + targetFullPath);
					return;
				}
			}
			
			ClickableQLabel* faceLabel = GetLabelForFace(i);
			if(faceLabel->GetRotation() != 0)
			{
				QTransform transform;
				transform.rotate(faceLabel->GetRotation());
				QImage qimg(targetFullPath.c_str());
				QImage rotatedImage = qimg.transformed(transform);
				rotatedImage.save(targetFullPath.c_str());
                faceLabel->SetRotation(0);
			}
		}
	}
	
	TextureDescriptor* descriptor = new TextureDescriptor();
    bool descriptorReady = false;
    if(filePath.Exists())
    {
        descriptorReady = descriptor->Load(filePath);
    }
    
    if(!descriptorReady)
    {
        descriptor->SetDefaultValues();
        descriptor->drawSettings.wrapModeS = descriptor->drawSettings.wrapModeT = Texture::WRAP_CLAMP_TO_EDGE;
    }
    
	descriptor->dataSettings.faceDescription = faceMask;

    descriptor->Save(filePath);
	SafeDelete(descriptor);
	
	QMessageBox::information(this, "Cubemap texture save result", "Cubemap texture was saved successfully!");
}
开发者ID:galek,项目名称:dava.framework,代码行数:86,代码来源:CubemapEditorDialog.cpp


注:本文中的FilePath::ReplaceFilename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。