3D PDF: Compilation fix

This commit is contained in:
Jakub Melka
2023-01-18 19:28:55 +01:00
parent fd6be53188
commit a8727c8dc4
8 changed files with 207 additions and 216 deletions

View File

@@ -43,7 +43,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(GNUInstallDirs)
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Svg Xml PrintSupport TextToSpeech OpenGL OpenGLWidgets Multimedia Network Test)
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Svg Xml PrintSupport TextToSpeech OpenGL OpenGLWidgets Multimedia Network Test 3dcore 3drender 3dinput 3dlogic 3dextras)
qt_standard_project_setup()
find_package(OpenSSL REQUIRED)

View File

@@ -91,6 +91,7 @@ add_library(Pdf4QtLib SHARED
sources/pdfnametounicode.cpp
sources/pdffont.cpp
sources/pdfimage.cpp
sources/pdf3d_u3d.cpp
sources/pdfcertificatemanagerdialog.ui
sources/pdfcreatecertificatedialog.ui
sources/pdfpagecontenteditorstylesettings.ui

View File

@@ -17,8 +17,8 @@
#include "pdf3d_u3d.h"
#include <QTextCodec>
#include <QImageReader>
#include <QStringConverter>
#include <array>
#include <algorithm>
@@ -1478,7 +1478,7 @@ public:
void processGenericBlock(const PDF3D_U3D_Block_Data& blockData, PDF3D_U3D_Block_Info::EPalette palette);
bool isCompressed() const { return m_isCompressed; }
QTextCodec* getTextCodec() const { return m_textCodec; }
QStringDecoder* getStringDecoder() { return &m_stringDecoder; }
PDF3D_U3D_AbstractBlockPtr parseBlock(uint32_t blockType, const QByteArray& data, const QByteArray& metaData);
PDF3D_U3D_AbstractBlockPtr parseBlock(const PDF3D_U3D_Block_Data& data);
@@ -1529,9 +1529,9 @@ private:
PDF3D_U3D_DecoderPalettes m_decoderPalettes;
PDF3D_U3D m_object;
PDF3D_U3D_AbstractBlockPtr m_fileBlock;
QTextCodec* m_textCodec = nullptr;
bool m_isCompressed = true;
uint32_t m_priority = 0;
QStringDecoder m_stringDecoder;
};
class PDF3D_U3D_DataReader
@@ -1564,8 +1564,8 @@ public:
void padTo32Bits();
QUuid readUuid();
QString readString(QTextCodec* textCodec);
QStringList readStringList(uint32_t count, QTextCodec* textCodec);
QString readString(QStringDecoder* textCodec);
QStringList readStringList(uint32_t count, QStringDecoder* stringDecoder);
QMatrix4x4 readMatrix4x4();
@@ -1584,7 +1584,7 @@ public:
uint32_t context3);
std::vector<PDF3D_U3D_ShadingDescription> readShadingDescriptions(uint32_t count);
std::vector<PDF3D_U3D_BoneDescription> readBoneDescriptions(QTextCodec* textCodec, uint32_t count);
std::vector<PDF3D_U3D_BoneDescription> readBoneDescriptions(QStringDecoder* stringDecoder, uint32_t count);
bool isAtEnd() const;
@@ -1822,7 +1822,7 @@ QUuid PDF3D_U3D_DataReader::readUuid()
return QUuid(A, B, C, D[0], D[1], D[2], D[3], D[4], D[5], D[6], D[7]);
}
QString PDF3D_U3D_DataReader::readString(QTextCodec* textCodec)
QString PDF3D_U3D_DataReader::readString(QStringDecoder* stringDecoder)
{
int size = readU16();
@@ -1833,17 +1833,17 @@ QString PDF3D_U3D_DataReader::readString(QTextCodec* textCodec)
encodedString[i] = readU8();
}
Q_ASSERT(textCodec);
return textCodec->toUnicode(encodedString);
Q_ASSERT(stringDecoder);
return stringDecoder->decode(encodedString);
}
QStringList PDF3D_U3D_DataReader::readStringList(uint32_t count, QTextCodec* textCodec)
QStringList PDF3D_U3D_DataReader::readStringList(uint32_t count, QStringDecoder* stringDecoder)
{
QStringList stringList;
for (uint32_t i = 0; i < count; ++i)
{
stringList << readString(textCodec);
stringList << readString(stringDecoder);
}
return stringList;
@@ -1923,7 +1923,7 @@ std::vector<PDF3D_U3D_ShadingDescription> PDF3D_U3D_DataReader::readShadingDescr
return result;
}
std::vector<PDF3D_U3D_BoneDescription> PDF3D_U3D_DataReader::readBoneDescriptions(QTextCodec* textCodec, uint32_t count)
std::vector<PDF3D_U3D_BoneDescription> PDF3D_U3D_DataReader::readBoneDescriptions(QStringDecoder* stringDecoder, uint32_t count)
{
std::vector<PDF3D_U3D_BoneDescription> result;
@@ -1931,8 +1931,8 @@ std::vector<PDF3D_U3D_BoneDescription> PDF3D_U3D_DataReader::readBoneDescription
{
PDF3D_U3D_BoneDescription item;
item.boneName = readString(textCodec);
item.parentBoneName = readString(textCodec);
item.boneName = readString(stringDecoder);
item.parentBoneName = readString(stringDecoder);
item.boneAttributes = readU32();
item.boneLength = readF32();
readFloats32(item.boneDisplacement);
@@ -2274,8 +2274,8 @@ PDF3D_U3D::PDF3D_U3D()
{
for (int j = 0; j < 4; ++j)
{
m_defaultTexture.setPixelColor(4 + i, j, QColor::fromRgbF(1.0, 0.4, 0.2, 1.0));
m_defaultTexture.setPixelColor(i, 4 + j, QColor::fromRgbF(1.0, 0.4, 0.2, 1.0));
m_defaultTexture.setPixelColor(4 + i, j, QColor::fromRgbF(1.0f, 0.4f, 0.2f, 1.0f));
m_defaultTexture.setPixelColor(i, 4 + j, QColor::fromRgbF(1.0f, 0.4f, 0.2f, 1.0f));
}
}
@@ -2621,9 +2621,9 @@ void PDF3D_U3D_Parser::processTexture(const PDF3D_U3D_Decoder& decoder)
const std::vector<PDF3D_U3D_TextureResourceBlock::ContinuationImageFormat>& formats = declarationBlock->getFormats();
for (size_t i = 0; i < formats.size(); ++i)
{
const PDF3D_U3D_TextureResourceBlock::ContinuationImageFormat& format = formats[i];
const PDF3D_U3D_TextureResourceBlock::ContinuationImageFormat& continuationFormat = formats[i];
if (format.isExternal())
if (continuationFormat.isExternal())
{
m_errors << PDFTranslationContext::tr("Textures with external images not supported.");
continue;
@@ -2653,7 +2653,7 @@ void PDF3D_U3D_Parser::processTexture(const PDF3D_U3D_Decoder& decoder)
{
if (image.hasAlphaChannel())
{
texture = image.alphaChannel();
texture = image.createAlphaMask();
}
else
{
@@ -3418,8 +3418,8 @@ void PDF3D_U3D_Parser::addBlockToU3D(PDF3D_U3D_AbstractBlockPtr block)
PDF3D_U3D_Parser::PDF3D_U3D_Parser()
{
// Jakub Melka: 106 is default value for U3D strings
m_textCodec = QTextCodec::codecForMib(106);
// Jakub Melka: Utf-8 (MIB 106) is default value for U3D strings
m_stringDecoder = QStringDecoder(QStringDecoder::Encoding::Utf8, QStringDecoder::Flag::Stateless);
}
PDF3D_U3D PDF3D_U3D_Parser::parse(QByteArray data)
@@ -3544,9 +3544,9 @@ void PDF3D_U3D_Parser::processModifierBlock(const PDF3D_U3D_Block_Data& blockDat
return;
}
for (const auto& block : chainBlock->getModifierDeclarationBlocks())
for (const auto& modifierDeclarationBlock : chainBlock->getModifierDeclarationBlocks())
{
processBlock(block, palette);
processBlock(modifierDeclarationBlock, palette);
}
}
@@ -3554,7 +3554,7 @@ void PDF3D_U3D_Parser::processGenericBlock(const PDF3D_U3D_Block_Data& blockData
PDF3D_U3D_Block_Info::EPalette palette)
{
PDF3D_U3D_DataReader blockReader(blockData.blockData, isCompressed());
QString blockName = blockReader.readString(getTextCodec());
QString blockName = blockReader.readString(getStringDecoder());
uint32_t chainIndex = 0;
PDF3D_U3D_Block_Info::EPalette effectivePalette = PDF3D_U3D_Block_Info::isChain(blockData.blockType) ? palette
@@ -3623,7 +3623,8 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_Parser::parseBlock(uint32_t blockType,
if (const PDF3D_U3D_FileBlock* fileBlock = dynamic_cast<const PDF3D_U3D_FileBlock*>(fileBlockPtr.get()))
{
m_fileBlock = fileBlockPtr;
m_textCodec = QTextCodec::codecForMib(fileBlock->getCharacterEncoding());
QStringDecoder::Encoding encoding = fileBlock->getCharacterEncoding() == 106 ? QStringDecoder::Utf8 : QStringDecoder::System;
m_stringDecoder = QStringDecoder(encoding, QStringDecoder::Flag::Stateless | QStringDecoder::Flag::UsesIcu);
m_isCompressed = !fileBlock->isNoCompressionMode();
}
@@ -3802,7 +3803,7 @@ void PDF3D_U3D_AbstractBlock::parseMetadata(QByteArray metaData, PDF3D_U3D_Parse
{
MetaDataItem item;
item.attributes = reader.readU32();
item.key = reader.readString(object->getTextCodec());
item.key = reader.readString(object->getStringDecoder());
if (item.attributes & 0x00000001)
{
@@ -3811,7 +3812,7 @@ void PDF3D_U3D_AbstractBlock::parseMetadata(QByteArray metaData, PDF3D_U3D_Parse
}
else
{
item.value = reader.readString(object->getTextCodec());
item.value = reader.readString(object->getStringDecoder());
}
m_metaData.emplace_back(std::move(item));
@@ -3828,7 +3829,7 @@ PDF3D_U3D_AbstractBlock::ParentNodesData PDF3D_U3D_AbstractBlock::parseParentNod
for (uint32_t i = 0; i < parentNodeCount; ++i)
{
ParentNodeData data;
data.parentNodeName = reader.readString(object->getTextCodec());
data.parentNodeName = reader.readString(object->getStringDecoder());
data.transformMatrix = reader.readMatrix4x4();
result.emplace_back(std::move(data));
}
@@ -3844,7 +3845,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_FileReferenceBlock::parse(QByteArray data,
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_scopeName = reader.readString(object->getTextCodec());
block->m_scopeName = reader.readString(object->getStringDecoder());
block->m_fileReferenceAttributes = reader.readU32();
if (block->isBoundingSpherePresent())
{
@@ -3855,7 +3856,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_FileReferenceBlock::parse(QByteArray data,
reader.readFloats32(block->m_boundingBox);
}
block->m_urlCount = reader.readU32();
block->m_urls = reader.readStringList(block->m_urlCount, object->getTextCodec());
block->m_urls = reader.readStringList(block->m_urlCount, object->getStringDecoder());
block->m_filterCount = reader.readU32();
for (uint32_t i = 0; i < block->m_filterCount; ++i)
@@ -3866,7 +3867,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_FileReferenceBlock::parse(QByteArray data,
switch (filter.filterType)
{
case 0x00:
filter.objectNameFilter = reader.readString(object->getTextCodec());
filter.objectNameFilter = reader.readString(object->getStringDecoder());
break;
case 0x01:
@@ -3881,7 +3882,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_FileReferenceBlock::parse(QByteArray data,
}
block->m_nameCollisionPolicy = reader.readU8();
block->m_worldAliasName = reader.readString(object->getTextCodec());
block->m_worldAliasName = reader.readString(object->getStringDecoder());
block->parseMetadata(metaData, object);
@@ -3946,7 +3947,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_ModifierChainBlock::parse(QByteArray data,
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_modifierChainName = reader.readString(object->getTextCodec());
block->m_modifierChainName = reader.readString(object->getStringDecoder());
block->m_modifierChainType = reader.readU32();
block->m_modifierChainAttributes = reader.readU32();
if (block->isBoundingSpherePresent())
@@ -4032,7 +4033,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_NewObjectTypeBlock::parse(QByteArray data,
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_newObjectTypeName = reader.readString(object->getTextCodec());
block->m_newObjectTypeName = reader.readString(object->getStringDecoder());
block->m_modifierType = reader.readU32();
block->m_extensionId = reader.readUuid();
block->m_newDeclarationBlockType = reader.readU32();
@@ -4043,10 +4044,10 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_NewObjectTypeBlock::parse(QByteArray data,
block->m_continuationBlockTypes.push_back(reader.readU32());
}
block->m_extensionVendorName = reader.readString(object->getTextCodec());
block->m_extensionVendorName = reader.readString(object->getStringDecoder());
block->m_urlCount = reader.readU32();
block->m_urls = reader.readStringList(block->m_urlCount, object->getTextCodec());
block->m_extensionInformationString = reader.readString(object->getTextCodec());
block->m_urls = reader.readStringList(block->m_urlCount, object->getStringDecoder());
block->m_extensionInformationString = reader.readString(object->getStringDecoder());
block->parseMetadata(metaData, object);
return pointer;
@@ -4110,7 +4111,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_NewObjectBlock::parse(QByteArray data, QByt
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_objectName = reader.readString(object->getTextCodec());
block->m_objectName = reader.readString(object->getStringDecoder());
block->m_chainIndex = reader.readU32();
block->m_data = reader.readRemainingData();
@@ -4141,7 +4142,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_GroupNodeBlock::parse(QByteArray data, QByt
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_groupNodeName = reader.readString(object->getTextCodec());
block->m_groupNodeName = reader.readString(object->getStringDecoder());
block->m_parentNodesData = parseParentNodeData(reader, object);
block->parseMetadata(metaData, object);
@@ -4166,9 +4167,9 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_ModelNodeBlock::parse(QByteArray data, QByt
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_modelNodeName = reader.readString(object->getTextCodec());
block->m_modelNodeName = reader.readString(object->getStringDecoder());
block->m_parentNodesData = parseParentNodeData(reader, object);
block->m_modelResourceName = reader.readString(object->getTextCodec());
block->m_modelResourceName = reader.readString(object->getStringDecoder());
block->m_modelVisibility = reader.readU32();
block->parseMetadata(metaData, object);
@@ -4203,9 +4204,9 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_LightNodeBlock::parse(QByteArray data, QByt
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_lightNodeName = reader.readString(object->getTextCodec());
block->m_lightNodeName = reader.readString(object->getStringDecoder());
block->m_parentNodesData = parseParentNodeData(reader, object);
block->m_lightResourceName = reader.readString(object->getTextCodec());
block->m_lightResourceName = reader.readString(object->getStringDecoder());
block->parseMetadata(metaData, object);
return pointer;
@@ -4234,9 +4235,9 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_ViewNodeBlock::parse(QByteArray data, QByte
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_viewNodeName = reader.readString(object->getTextCodec());
block->m_viewNodeName = reader.readString(object->getStringDecoder());
block->m_parentNodesData = parseParentNodeData(reader, object);
block->m_viewResourceName = reader.readString(object->getTextCodec());
block->m_viewResourceName = reader.readString(object->getStringDecoder());
block->m_viewNodeAttributes = reader.readU32();
block->m_viewNearFlipping = reader.readF32();
block->m_viewFarFlipping = reader.readF32();
@@ -4271,7 +4272,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_ViewNodeBlock::parse(QByteArray data, QByte
{
BackdropOrOverlay item;
item.m_textureName = reader.readString(object->getTextCodec());
item.m_textureName = reader.readString(object->getStringDecoder());
item.m_textureBlend = reader.readF32();
item.m_rotation = reader.readF32();
item.m_locationX = reader.readF32();
@@ -4380,7 +4381,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_CLODMeshDeclarationBlock::parse(QByteArray
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_meshName = reader.readString(object->getTextCodec());
block->m_meshName = reader.readString(object->getStringDecoder());
block->m_chainIndex = reader.readU32();
/* max mesh description */
@@ -4412,7 +4413,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_CLODMeshDeclarationBlock::parse(QByteArray
/* bone description */
block->m_boneCount = reader.readU32();
block->m_boneDescription = reader.readBoneDescriptions(object->getTextCodec(), block->m_boneCount);
block->m_boneDescription = reader.readBoneDescriptions(object->getStringDecoder(), block->m_boneCount);
block->parseMetadata(metaData, object);
return pointer;
@@ -4554,7 +4555,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_CLODBaseMeshContinuationBlock::parse(QByteA
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_meshName = reader.readString(object->getTextCodec());
block->m_meshName = reader.readString(object->getStringDecoder());
block->m_chainIndex = reader.readU32();
/* max mesh description */
@@ -4689,7 +4690,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_CLODProgressiveMeshContinuationBlock::parse
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_meshName = reader.readString(object->getTextCodec());
block->m_meshName = reader.readString(object->getStringDecoder());
block->m_chainIndex = reader.readU32();
block->m_startResolution = reader.readU32();
@@ -4792,7 +4793,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_LineSetDeclarationBlock::parse(QByteArray d
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_lineSetName = reader.readString(object->getTextCodec());
block->m_lineSetName = reader.readString(object->getStringDecoder());
block->m_chainIndex = reader.readU32();
// line set description
@@ -4908,7 +4909,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_LineSetContinuationBlock::parse(QByteArray
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_lineSetName = reader.readString(object->getTextCodec());
block->m_lineSetName = reader.readString(object->getStringDecoder());
block->m_chainIndex = reader.readU32();
block->m_startResolution = reader.readU32();
@@ -5171,7 +5172,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_PointSetDeclarationBlock::parse(QByteArray
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_pointSetName = reader.readString(object->getTextCodec());
block->m_pointSetName = reader.readString(object->getStringDecoder());
block->m_chainIndex = reader.readU32();
// point set description
@@ -5199,7 +5200,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_PointSetDeclarationBlock::parse(QByteArray
/* bone description */
block->m_boneCount = reader.readU32();
block->m_boneDescription = reader.readBoneDescriptions(object->getTextCodec(), block->m_boneCount);
block->m_boneDescription = reader.readBoneDescriptions(object->getStringDecoder(), block->m_boneCount);
block->parseMetadata(metaData, object);
return pointer;
@@ -5301,7 +5302,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_PointSetContinuationBlock::parse(QByteArray
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_pointSetName = reader.readString(object->getTextCodec());
block->m_pointSetName = reader.readString(object->getStringDecoder());
block->m_chainIndex = reader.readU32();
block->m_startResolution = reader.readU32();
@@ -5413,7 +5414,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_2DGlyphModifierBlock::parse(QByteArray data
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_modifierName = reader.readString(object->getTextCodec());
block->m_modifierName = reader.readString(object->getStringDecoder());
block->m_chainIndex = reader.readU32();
block->m_glyphAttributes = reader.readU32();
@@ -5535,7 +5536,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_SubdivisionModifierBlock::parse(QByteArray
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_modifierName = reader.readString(object->getTextCodec());
block->m_modifierName = reader.readString(object->getStringDecoder());
block->m_chainIndex = reader.readU32();
block->m_attributes = reader.readU32();
block->m_depth = reader.readU32();
@@ -5586,7 +5587,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_AnimationModifierBlock::parse(QByteArray da
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_modifierName = reader.readString(object->getTextCodec());
block->m_modifierName = reader.readString(object->getStringDecoder());
block->m_chainIndex = reader.readU32();
block->m_attributes = reader.readU32();
block->m_timescale = reader.readF32();
@@ -5595,7 +5596,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_AnimationModifierBlock::parse(QByteArray da
for (uint32_t i = 0; i < motionCount; ++i)
{
MotionInformation item;
item.motionName = reader.readString(object->getTextCodec());
item.motionName = reader.readString(object->getStringDecoder());
item.motionAttributes = reader.readU32();
item.timeOffset = reader.readF32();
item.timeScale = reader.readF32();
@@ -5643,7 +5644,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_BoneWeightModifierBlock::parse(QByteArray d
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_modifierName = reader.readString(object->getTextCodec());
block->m_modifierName = reader.readString(object->getStringDecoder());
block->m_chainIndex = reader.readU32();
block->m_attributes = reader.readU32();
block->m_inverseQuant = reader.readF32();
@@ -5691,7 +5692,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_ShadingModifierBlock::parse(QByteArray data
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_modifierName = reader.readString(object->getTextCodec());
block->m_modifierName = reader.readString(object->getStringDecoder());
block->m_chainIndex = reader.readU32();
block->m_attributes = reader.readU32();
@@ -5701,9 +5702,9 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_ShadingModifierBlock::parse(QByteArray data
QStringList shaderNames;
uint32_t shaderCount = reader.readU32();
for (uint32_t i = 0; i < shaderCount; ++i)
for (uint32_t j = 0; j < shaderCount; ++j)
{
shaderNames << reader.readString(object->getTextCodec());
shaderNames << reader.readString(object->getStringDecoder());
}
block->m_shaderLists.emplace_back(std::move(shaderNames));
@@ -5743,7 +5744,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_CLODModifierBlock::parse(QByteArray data,
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_modifierName = reader.readString(object->getTextCodec());
block->m_modifierName = reader.readString(object->getStringDecoder());
block->m_chainIndex = reader.readU32();
block->m_attributes = reader.readU32();
block->m_CLODAutomaticLevelOfDetails = reader.readF32();
@@ -5773,7 +5774,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_LightResourceBlock::parse(QByteArray data,
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_resourceName = reader.readString(object->getTextCodec());
block->m_resourceName = reader.readString(object->getStringDecoder());
block->m_attributes = reader.readU32();
block->m_type = reader.readU8();
reader.readFloats32(block->m_color);
@@ -5830,14 +5831,14 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_ViewResourceBlock::parse(QByteArray data,
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_resourceName = reader.readString(object->getTextCodec());
block->m_resourceName = reader.readString(object->getStringDecoder());
const uint32_t passCount = reader.readU32();
for (uint32_t i = 0; i < passCount; ++i)
{
Pass pass;
pass.rootNodeName = reader.readString(object->getTextCodec());
pass.rootNodeName = reader.readString(object->getStringDecoder());
pass.renderAttributes = reader.readU32();
pass.fogMode = reader.readU32();
reader.readFloats32(pass.fogColor);
@@ -5871,7 +5872,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_LitTextureShaderResourceBlock::parse(QByteA
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_resourceName = reader.readString(object->getTextCodec());
block->m_resourceName = reader.readString(object->getStringDecoder());
block->m_attributes = reader.readU32();
block->m_alphaTestReference = reader.readF32();
block->m_alphaTestFunction = reader.readU32();
@@ -5879,7 +5880,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_LitTextureShaderResourceBlock::parse(QByteA
block->m_renderPassEnabled = reader.readU32();
block->m_shaderChannels = reader.readU32();
block->m_alphaTextureChannels = reader.readU32();
block->m_materialName = reader.readString(object->getTextCodec());
block->m_materialName = reader.readString(object->getStringDecoder());
uint32_t value = block->m_shaderChannels & 0xFF;
uint32_t activeChannelCount = 0;
@@ -5892,7 +5893,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_LitTextureShaderResourceBlock::parse(QByteA
{
TextureInfo info;
info.textureName = reader.readString(object->getTextCodec());
info.textureName = reader.readString(object->getStringDecoder());
info.textureIntensity = reader.readF32();
info.blendFunction = reader.readU8();
info.blendSource = reader.readU8();
@@ -5969,7 +5970,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_MaterialResourceBlock::parse(QByteArray dat
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_resourceName = reader.readString(object->getTextCodec());
block->m_resourceName = reader.readString(object->getStringDecoder());
block->m_materialAttributes = reader.readU32();
reader.readFloats32(block->m_ambientColor);
reader.readFloats32(block->m_diffuseColor);
@@ -6032,7 +6033,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_TextureResourceBlock::parse(QByteArray data
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_resourceName = reader.readString(object->getTextCodec());
block->m_resourceName = reader.readString(object->getStringDecoder());
block->m_textureHeight = reader.readU32();
block->m_textureWidth = reader.readU32();
block->m_type = reader.readU8();
@@ -6053,7 +6054,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_TextureResourceBlock::parse(QByteArray data
else
{
format.imageURLCount = reader.readU32();
format.imageURLs = reader.readStringList(format.imageURLCount, object->getTextCodec());
format.imageURLs = reader.readStringList(format.imageURLCount, object->getStringDecoder());
}
block->m_formats.emplace_back(std::move(format));
@@ -6096,7 +6097,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_TextureContinuationResourceBlock::parse(QBy
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_resourceName = reader.readString(object->getTextCodec());
block->m_resourceName = reader.readString(object->getStringDecoder());
block->m_imageIndex = reader.readU32();
block->m_imageData = reader.readRemainingData();
@@ -6202,7 +6203,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_MotionResourceBlock::parse(QByteArray data,
PDF3D_U3D_DataReader reader(data, object->isCompressed());
// Read the data
block->m_resourceName = reader.readString(object->getTextCodec());
block->m_resourceName = reader.readString(object->getStringDecoder());
block->m_trackCount = reader.readU32();
block->m_timeInverseQuant = reader.readF32();
block->m_rotationInverseQuant = reader.readF32();
@@ -6211,7 +6212,7 @@ PDF3D_U3D_AbstractBlockPtr PDF3D_U3D_MotionResourceBlock::parse(QByteArray data,
{
Motion motion;
motion.trackName = reader.readString(object->getTextCodec());
motion.trackName = reader.readString(object->getStringDecoder());
motion.timeCount = reader.readU32();
motion.displacementInverseQuant = reader.readF32();
motion.rotationInverseQuant = reader.readF32();

View File

@@ -1992,7 +1992,7 @@ void PDFWidgetAnnotationManager::updateFromMouseEvent(QMouseEvent* event)
const PDFAnnotation* annotation = pageAnnotation.annotation.get();
if (PDFAnnotation::isTypeMultimedia(annotation->getType()))
{
emit multimediaTriggered(annotation);
Q_EMIT multimediaTriggered(annotation);
}
}
}

View File

@@ -34,6 +34,8 @@ add_library(Pdf4QtViewer SHARED
pdfviewersettings.cpp
pdfviewersettingsdialog.cpp
pdfwintaskbarprogress.cpp
pdfmediaviewerdialog.cpp
pdf3dsceneprocessor.cpp
pdfaboutdialog.ui
pdfadvancedfindwidget.ui
pdfdocumentpropertiesdialog.ui
@@ -59,7 +61,7 @@ GENERATE_EXPORT_HEADER(Pdf4QtViewer
PDF4QTVIEWERLIBSHARED_EXPORT
EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}/pdf4qtviewer_export.h")
target_link_libraries(Pdf4QtViewer PRIVATE Pdf4QtLib Qt6::Core Qt6::Gui Qt6::Widgets Qt6::PrintSupport Qt6::TextToSpeech Qt6::Xml Qt6::OpenGLWidgets)
target_link_libraries(Pdf4QtViewer PRIVATE Pdf4QtLib Qt6::Core Qt6::Gui Qt6::Widgets Qt6::PrintSupport Qt6::TextToSpeech Qt6::Xml Qt6::OpenGLWidgets Qt6::3DCore Qt6::3DRender Qt6::3DInput Qt6::3DLogic Qt6::3DExtras)
target_include_directories(Pdf4QtViewer INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(Pdf4QtViewer PUBLIC ${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR})

View File

@@ -23,13 +23,13 @@
#include <Qt3DCore/QEntity>
#include <Qt3DCore/QTransform>
#include <Qt3DCore/QAttribute>
#include <Qt3DCore/QGeometry>
#include <Qt3DCore/QBuffer>
#include <Qt3DRender/QSpotLight>
#include <Qt3DRender/QPointLight>
#include <Qt3DRender/QDirectionalLight>
#include <Qt3DRender/QAttribute>
#include <Qt3DRender/QGeometry>
#include <Qt3DRender/QGeometryRenderer>
#include <Qt3DRender/QBuffer>
#include <Qt3DRender/QPointSize>
#include <Qt3DRender/QEffect>
#include <Qt3DRender/QTechnique>
@@ -537,11 +537,10 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createMeshGeometry(const pdf::u3d::PDF3D_U
// We will display vertices with triangle color
// Vertex buffer
Qt3DRender::QAttribute* positionAttribute = createPositionAttribute(meshGeometry->getPositions());
Qt3DCore::QAttribute* positionAttribute = createPositionAttribute(meshGeometry->getPositions());
// Color buffer
Qt3DRender::QBuffer* colorBuffer = new Qt3DRender::QBuffer();
colorBuffer->setType(Qt3DRender::QBuffer::VertexBuffer);
Qt3DCore::QBuffer* colorBuffer = new Qt3DCore::QBuffer();
const uint positionCount = positionAttribute->count();
QByteArray colorBufferData;
@@ -572,18 +571,18 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createMeshGeometry(const pdf::u3d::PDF3D_U
}
colorBuffer->setData(colorBufferData);
Qt3DRender::QAttribute* colorAttribute = new Qt3DRender::QAttribute();
colorAttribute->setName(Qt3DRender::QAttribute::defaultColorAttributeName());
colorAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float);
Qt3DCore::QAttribute* colorAttribute = new Qt3DCore::QAttribute();
colorAttribute->setName(Qt3DCore::QAttribute::defaultColorAttributeName());
colorAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float);
colorAttribute->setVertexSize(3);
colorAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
colorAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute);
colorAttribute->setBuffer(colorBuffer);
colorAttribute->setByteOffset(0);
colorAttribute->setByteStride(3 * sizeof(float));
colorAttribute->setCount(positionCount);
// Geometry
Qt3DRender::QGeometry* geometry = new Qt3DRender::QGeometry();
Qt3DCore::QGeometry* geometry = new Qt3DCore::QGeometry();
geometry->addAttribute(positionAttribute);
geometry->addAttribute(colorAttribute);
@@ -711,11 +710,10 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createPointSetGeometry(const pdf::u3d::PDF
// We will display vertices with line color
// Vertex buffer
Qt3DRender::QAttribute* positionAttribute = createPositionAttribute(pointSetGeometry->getPositions());
Qt3DCore::QAttribute* positionAttribute = createPositionAttribute(pointSetGeometry->getPositions());
// Color buffer
Qt3DRender::QBuffer* colorBuffer = new Qt3DRender::QBuffer();
colorBuffer->setType(Qt3DRender::QBuffer::VertexBuffer);
Qt3DCore::QBuffer* colorBuffer = new Qt3DCore::QBuffer();
const uint positionCount = positionAttribute->count();
QByteArray colorBufferData;
@@ -751,18 +749,18 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createPointSetGeometry(const pdf::u3d::PDF
}
colorBuffer->setData(colorBufferData);
Qt3DRender::QAttribute* colorAttribute = new Qt3DRender::QAttribute();
colorAttribute->setName(Qt3DRender::QAttribute::defaultColorAttributeName());
colorAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float);
Qt3DCore::QAttribute* colorAttribute = new Qt3DCore::QAttribute();
colorAttribute->setName(Qt3DCore::QAttribute::defaultColorAttributeName());
colorAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float);
colorAttribute->setVertexSize(3);
colorAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
colorAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute);
colorAttribute->setBuffer(colorBuffer);
colorAttribute->setByteOffset(0);
colorAttribute->setByteStride(3 * sizeof(float));
colorAttribute->setCount(positionCount);
// Geometry
Qt3DRender::QGeometry* geometry = new Qt3DRender::QGeometry();
Qt3DCore::QGeometry* geometry = new Qt3DCore::QGeometry();
geometry->addAttribute(positionAttribute);
geometry->addAttribute(colorAttribute);
@@ -869,7 +867,7 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createLineSetGeometry(const pdf::u3d::PDF3
// We will display lines colored by auxiliary color
// Vertex buffer
Qt3DRender::QAttribute* positionAttribute = createPositionAttribute(lineSetGeometry->getPositions());
Qt3DCore::QAttribute* positionAttribute = createPositionAttribute(lineSetGeometry->getPositions());
// Index buffer
uint lineCount = static_cast<uint>(lineSetGeometry->getLineCount());
@@ -877,8 +875,7 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createLineSetGeometry(const pdf::u3d::PDF3
indexBufferData.resize(lineCount * 2 * sizeof(unsigned int));
unsigned int* indexBufferDataPtr = reinterpret_cast<unsigned int*>(indexBufferData.data());
Qt3DRender::QBuffer* indexBuffer = new Qt3DRender::QBuffer();
indexBuffer->setType(Qt3DRender::QBuffer::IndexBuffer);
Qt3DCore::QBuffer* indexBuffer = new Qt3DCore::QBuffer();
for (size_t i = 0; i < lineCount; ++i)
{
@@ -888,14 +885,14 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createLineSetGeometry(const pdf::u3d::PDF3
}
indexBuffer->setData(indexBufferData);
Qt3DRender::QAttribute* indexAttribute = new Qt3DRender::QAttribute();
indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute);
indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt);
Qt3DCore::QAttribute* indexAttribute = new Qt3DCore::QAttribute();
indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute);
indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedInt);
indexAttribute->setBuffer(indexBuffer);
indexAttribute->setCount(2 * lineCount);
// Geometry
Qt3DRender::QGeometry* geometry = new Qt3DRender::QGeometry();
Qt3DCore::QGeometry* geometry = new Qt3DCore::QGeometry();
geometry->addAttribute(positionAttribute);
geometry->addAttribute(indexAttribute);
@@ -975,11 +972,11 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createLineSetGeometry(const pdf::u3d::PDF3
colors.push_back(color2);
}
Qt3DRender::QAttribute* positionAttribute = createPositionAttribute(positions);
Qt3DRender::QAttribute* colorAttribute = createColorAttribute(colors);
Qt3DCore::QAttribute* positionAttribute = createPositionAttribute(positions);
Qt3DCore::QAttribute* colorAttribute = createColorAttribute(colors);
// Geometry
Qt3DRender::QGeometry* geometry = new Qt3DRender::QGeometry();
Qt3DCore::QGeometry* geometry = new Qt3DCore::QGeometry();
geometry->addAttribute(positionAttribute);
geometry->addAttribute(colorAttribute);
@@ -1025,11 +1022,10 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createLineSetGeometry(const pdf::u3d::PDF3
// We will display vertices with line color
// Vertex buffer
Qt3DRender::QAttribute* positionAttribute = createPositionAttribute(lineSetGeometry->getPositions());
Qt3DCore::QAttribute* positionAttribute = createPositionAttribute(lineSetGeometry->getPositions());
// Color buffer
Qt3DRender::QBuffer* colorBuffer = new Qt3DRender::QBuffer();
colorBuffer->setType(Qt3DRender::QBuffer::VertexBuffer);
Qt3DCore::QBuffer* colorBuffer = new Qt3DCore::QBuffer();
const uint positionCount = positionAttribute->count();
QByteArray colorBufferData;
@@ -1062,18 +1058,18 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createLineSetGeometry(const pdf::u3d::PDF3
}
colorBuffer->setData(colorBufferData);
Qt3DRender::QAttribute* colorAttribute = new Qt3DRender::QAttribute();
colorAttribute->setName(Qt3DRender::QAttribute::defaultColorAttributeName());
colorAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float);
Qt3DCore::QAttribute* colorAttribute = new Qt3DCore::QAttribute();
colorAttribute->setName(Qt3DCore::QAttribute::defaultColorAttributeName());
colorAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float);
colorAttribute->setVertexSize(3);
colorAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
colorAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute);
colorAttribute->setBuffer(colorBuffer);
colorAttribute->setByteOffset(0);
colorAttribute->setByteStride(3 * sizeof(float));
colorAttribute->setCount(positionCount);
// Geometry
Qt3DRender::QGeometry* geometry = new Qt3DRender::QGeometry();
Qt3DCore::QGeometry* geometry = new Qt3DCore::QGeometry();
geometry->addAttribute(positionAttribute);
geometry->addAttribute(colorAttribute);
@@ -1115,10 +1111,10 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createLineSetGeometry(const pdf::u3d::PDF3
Qt3DCore::QNode* PDF3DSceneProcessor::createVertexGeometry(const std::vector<QVector3D>& positions)
{
// Vertex buffer
Qt3DRender::QAttribute* positionAttribute = createPositionAttribute(positions);
Qt3DCore::QAttribute* positionAttribute = createPositionAttribute(positions);
// Geometry
Qt3DRender::QGeometry* geometry = new Qt3DRender::QGeometry();
Qt3DCore::QGeometry* geometry = new Qt3DCore::QGeometry();
geometry->addAttribute(positionAttribute);
Qt3DRender::QGeometryRenderer* geometryRenderer = new Qt3DRender::QGeometryRenderer();
@@ -1183,8 +1179,7 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createBoundingBoxWireGeometry(const PDF3DB
};
// Vertex buffer
Qt3DRender::QBuffer* vertexBuffer = new Qt3DRender::QBuffer();
vertexBuffer->setType(Qt3DRender::QBuffer::VertexBuffer);
Qt3DCore::QBuffer* vertexBuffer = new Qt3DCore::QBuffer();
uint positionCount = static_cast<uint>(positions.size());
QByteArray vertexBufferData;
@@ -1200,11 +1195,11 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createBoundingBoxWireGeometry(const PDF3DB
}
vertexBuffer->setData(vertexBufferData);
Qt3DRender::QAttribute* positionAttribute = new Qt3DRender::QAttribute();
positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName());
positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float);
Qt3DCore::QAttribute* positionAttribute = new Qt3DCore::QAttribute();
positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName());
positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float);
positionAttribute->setVertexSize(3);
positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute);
positionAttribute->setBuffer(vertexBuffer);
positionAttribute->setByteOffset(0);
positionAttribute->setByteStride(3 * sizeof(float));
@@ -1216,8 +1211,7 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createBoundingBoxWireGeometry(const PDF3DB
indexBufferData.resize(lineCount * 2 * sizeof(unsigned int));
unsigned int* indexBufferDataPtr = reinterpret_cast<unsigned int*>(indexBufferData.data());
Qt3DRender::QBuffer* indexBuffer = new Qt3DRender::QBuffer();
indexBuffer->setType(Qt3DRender::QBuffer::IndexBuffer);
Qt3DCore::QBuffer* indexBuffer = new Qt3DCore::QBuffer();
for (size_t i = 0; i < indices.size(); ++i)
{
@@ -1225,14 +1219,14 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createBoundingBoxWireGeometry(const PDF3DB
}
indexBuffer->setData(indexBufferData);
Qt3DRender::QAttribute* indexAttribute = new Qt3DRender::QAttribute();
indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute);
indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt);
Qt3DCore::QAttribute* indexAttribute = new Qt3DCore::QAttribute();
indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute);
indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedInt);
indexAttribute->setBuffer(indexBuffer);
indexAttribute->setCount(2 * lineCount);
// Geometry
Qt3DRender::QGeometry* geometry = new Qt3DRender::QGeometry();
Qt3DCore::QGeometry* geometry = new Qt3DCore::QGeometry();
geometry->addAttribute(positionAttribute);
geometry->addAttribute(indexAttribute);
@@ -1286,8 +1280,7 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createBoundingBoxTransparentGeometry(const
};
// Vertex buffer
Qt3DRender::QBuffer* vertexBuffer = new Qt3DRender::QBuffer();
vertexBuffer->setType(Qt3DRender::QBuffer::VertexBuffer);
Qt3DCore::QBuffer* vertexBuffer = new Qt3DCore::QBuffer();
uint positionCount = static_cast<uint>(positions.size());
QByteArray vertexBufferData;
@@ -1303,11 +1296,11 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createBoundingBoxTransparentGeometry(const
}
vertexBuffer->setData(vertexBufferData);
Qt3DRender::QAttribute* positionAttribute = new Qt3DRender::QAttribute();
positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName());
positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float);
Qt3DCore::QAttribute* positionAttribute = new Qt3DCore::QAttribute();
positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName());
positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float);
positionAttribute->setVertexSize(3);
positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute);
positionAttribute->setBuffer(vertexBuffer);
positionAttribute->setByteOffset(0);
positionAttribute->setByteStride(3 * sizeof(float));
@@ -1319,8 +1312,7 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createBoundingBoxTransparentGeometry(const
indexBufferData.resize(triangleCount * 3 * sizeof(unsigned int));
unsigned int* indexBufferDataPtr = reinterpret_cast<unsigned int*>(indexBufferData.data());
Qt3DRender::QBuffer* indexBuffer = new Qt3DRender::QBuffer();
indexBuffer->setType(Qt3DRender::QBuffer::IndexBuffer);
Qt3DCore::QBuffer* indexBuffer = new Qt3DCore::QBuffer();
for (size_t i = 0; i < indices.size(); ++i)
{
@@ -1328,14 +1320,14 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createBoundingBoxTransparentGeometry(const
}
indexBuffer->setData(indexBufferData);
Qt3DRender::QAttribute* indexAttribute = new Qt3DRender::QAttribute();
indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute);
indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt);
Qt3DCore::QAttribute* indexAttribute = new Qt3DCore::QAttribute();
indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute);
indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedInt);
indexAttribute->setBuffer(indexBuffer);
indexAttribute->setCount(3 * triangleCount);
// Geometry
Qt3DRender::QGeometry* geometry = new Qt3DRender::QGeometry();
Qt3DCore::QGeometry* geometry = new Qt3DCore::QGeometry();
geometry->addAttribute(positionAttribute);
geometry->addAttribute(indexAttribute);
@@ -1375,7 +1367,7 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createBoundingBoxTransparentGeometry(const
Qt3DCore::QNode* PDF3DSceneProcessor::createWireframeMeshGeometry(const pdf::u3d::PDF3D_U3D_MeshGeometry* meshGeometry)
{
// Vertex buffer
Qt3DRender::QAttribute* positionAttribute = createPositionAttribute(meshGeometry->getPositions());
Qt3DCore::QAttribute* positionAttribute = createPositionAttribute(meshGeometry->getPositions());
// Index buffer
uint lineCount = static_cast<uint>(meshGeometry->getTriangleCount()) * 3;
@@ -1383,8 +1375,7 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createWireframeMeshGeometry(const pdf::u3d
indexBufferData.resize(lineCount * 2 * sizeof(unsigned int));
unsigned int* indexBufferDataPtr = reinterpret_cast<unsigned int*>(indexBufferData.data());
Qt3DRender::QBuffer* indexBuffer = new Qt3DRender::QBuffer();
indexBuffer->setType(Qt3DRender::QBuffer::IndexBuffer);
Qt3DCore::QBuffer* indexBuffer = new Qt3DCore::QBuffer();
for (const pdf::u3d::PDF3D_U3D_MeshGeometry::Triangle& triangle : meshGeometry->getTriangles())
{
@@ -1397,14 +1388,14 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createWireframeMeshGeometry(const pdf::u3d
}
indexBuffer->setData(indexBufferData);
Qt3DRender::QAttribute* indexAttribute = new Qt3DRender::QAttribute();
indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute);
indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt);
Qt3DCore::QAttribute* indexAttribute = new Qt3DCore::QAttribute();
indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute);
indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedInt);
indexAttribute->setBuffer(indexBuffer);
indexAttribute->setCount(2 * lineCount);
// Geometry
Qt3DRender::QGeometry* geometry = new Qt3DRender::QGeometry();
Qt3DCore::QGeometry* geometry = new Qt3DCore::QGeometry();
geometry->addAttribute(positionAttribute);
geometry->addAttribute(indexAttribute);
@@ -1466,8 +1457,7 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createSolidMeshGeometry(const pdf::u3d::PD
vertexBufferData.resize(triangleCount * 3 * stride);
float* vertexBufferDataPtr = reinterpret_cast<float*>(vertexBufferData.data());
Qt3DRender::QBuffer* vertexBuffer = new Qt3DRender::QBuffer();
vertexBuffer->setType(Qt3DRender::QBuffer::VertexBuffer);
Qt3DCore::QBuffer* vertexBuffer = new Qt3DCore::QBuffer();
for (const pdf::u3d::PDF3D_U3D_MeshGeometry::Triangle& triangle : triangles)
{
@@ -1475,14 +1465,14 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createSolidMeshGeometry(const pdf::u3d::PD
{
QVector3D position = meshGeometry->getPosition(vertex.positionIndex);
QVector3D normal = meshGeometry->getNormal(vertex.normalIndex);
QVector4D diffuseColor = meshGeometry->getDiffuseColor(vertex.diffuseColorIndex);
QVector4D diffuseVertexColor = meshGeometry->getDiffuseColor(vertex.diffuseColorIndex);
QVector4D textureCoordinate = meshGeometry->getTextureCoordinate(vertex.textureCoordIndex);
diffuseColor.setW(diffuseColor.w() * opacity);
diffuseVertexColor.setW(diffuseVertexColor.w() * opacity);
if (vertex.diffuseColorIndex == 0)
{
diffuseColor = defaultColor;
diffuseVertexColor = defaultColor;
}
// Vertex
@@ -1496,10 +1486,10 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createSolidMeshGeometry(const pdf::u3d::PD
*vertexBufferDataPtr++ = normal[2];
// Diffuse
*vertexBufferDataPtr++ = diffuseColor[0];
*vertexBufferDataPtr++ = diffuseColor[1];
*vertexBufferDataPtr++ = diffuseColor[2];
*vertexBufferDataPtr++ = diffuseColor[3];
*vertexBufferDataPtr++ = diffuseVertexColor[0];
*vertexBufferDataPtr++ = diffuseVertexColor[1];
*vertexBufferDataPtr++ = diffuseVertexColor[2];
*vertexBufferDataPtr++ = diffuseVertexColor[3];
// Texture coordinate
*vertexBufferDataPtr++ = textureCoordinate[0];
@@ -1511,51 +1501,51 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createSolidMeshGeometry(const pdf::u3d::PD
vertexBuffer->setData(vertexBufferData);
// Position attribute
Qt3DRender::QAttribute* positionAttribute = new Qt3DRender::QAttribute();
positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName());
positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
positionAttribute->setDataType(Qt3DRender::QAttribute::Float);
positionAttribute->setDataSize(positionVertexSize);
Qt3DCore::QAttribute* positionAttribute = new Qt3DCore::QAttribute();
positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName());
positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute);
positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float);
positionAttribute->setVertexSize(positionVertexSize);
positionAttribute->setBuffer(vertexBuffer);
positionAttribute->setByteOffset(positionVertexByteOffset);
positionAttribute->setByteStride(stride);
positionAttribute->setCount(triangleCount * 3);
// Normal attribute
Qt3DRender::QAttribute* normalAttribute = new Qt3DRender::QAttribute();
normalAttribute->setName(Qt3DRender::QAttribute::defaultNormalAttributeName());
normalAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
normalAttribute->setDataType(Qt3DRender::QAttribute::Float);
normalAttribute->setDataSize(normalVertexSize);
Qt3DCore::QAttribute* normalAttribute = new Qt3DCore::QAttribute();
normalAttribute->setName(Qt3DCore::QAttribute::defaultNormalAttributeName());
normalAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute);
normalAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float);
normalAttribute->setVertexSize(normalVertexSize);
normalAttribute->setBuffer(vertexBuffer);
normalAttribute->setByteOffset(normalVertexByteOffset);
normalAttribute->setByteStride(stride);
normalAttribute->setCount(triangleCount * 3);
// Color attribute
Qt3DRender::QAttribute* colorAttribute = new Qt3DRender::QAttribute();
colorAttribute->setName(Qt3DRender::QAttribute::defaultColorAttributeName());
colorAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
colorAttribute->setDataType(Qt3DRender::QAttribute::Float);
colorAttribute->setDataSize(colorVertexSize);
Qt3DCore::QAttribute* colorAttribute = new Qt3DCore::QAttribute();
colorAttribute->setName(Qt3DCore::QAttribute::defaultColorAttributeName());
colorAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute);
colorAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float);
colorAttribute->setVertexSize(colorVertexSize);
colorAttribute->setBuffer(vertexBuffer);
colorAttribute->setByteOffset(colorVertexByteOffset);
colorAttribute->setByteStride(stride);
colorAttribute->setCount(triangleCount * 3);
// Texture attribute
Qt3DRender::QAttribute* textureAttribute = new Qt3DRender::QAttribute();
textureAttribute->setName(Qt3DRender::QAttribute::defaultTextureCoordinateAttributeName());
textureAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
textureAttribute->setDataType(Qt3DRender::QAttribute::Float);
textureAttribute->setDataSize(textureVertexSize);
Qt3DCore::QAttribute* textureAttribute = new Qt3DCore::QAttribute();
textureAttribute->setName(Qt3DCore::QAttribute::defaultTextureCoordinateAttributeName());
textureAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute);
textureAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float);
textureAttribute->setVertexSize(textureVertexSize);
textureAttribute->setBuffer(vertexBuffer);
textureAttribute->setByteOffset(textureVertexByteOffset);
textureAttribute->setByteStride(stride);
textureAttribute->setCount(triangleCount * 3);
// Geometry
Qt3DRender::QGeometry* geometry = new Qt3DRender::QGeometry();
Qt3DCore::QGeometry* geometry = new Qt3DCore::QGeometry();
geometry->addAttribute(positionAttribute);
geometry->addAttribute(normalAttribute);
geometry->addAttribute(colorAttribute);
@@ -1606,8 +1596,7 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createSolidSingleColoredFaceGeometry(const
vertexBufferData.resize(triangleCount * 3 * stride);
float* vertexBufferDataPtr = reinterpret_cast<float*>(vertexBufferData.data());
Qt3DRender::QBuffer* vertexBuffer = new Qt3DRender::QBuffer();
vertexBuffer->setType(Qt3DRender::QBuffer::VertexBuffer);
Qt3DCore::QBuffer* vertexBuffer = new Qt3DCore::QBuffer();
for (const pdf::u3d::PDF3D_U3D_MeshGeometry::Triangle& triangle : triangles)
{
@@ -1626,18 +1615,18 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createSolidSingleColoredFaceGeometry(const
vertexBuffer->setData(vertexBufferData);
// Position attribute
Qt3DRender::QAttribute* positionAttribute = new Qt3DRender::QAttribute();
positionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName());
positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
positionAttribute->setDataType(Qt3DRender::QAttribute::Float);
positionAttribute->setDataSize(positionVertexSize);
Qt3DCore::QAttribute* positionAttribute = new Qt3DCore::QAttribute();
positionAttribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName());
positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute);
positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float);
positionAttribute->setVertexSize(positionVertexSize);
positionAttribute->setBuffer(vertexBuffer);
positionAttribute->setByteOffset(positionVertexByteOffset);
positionAttribute->setByteStride(stride);
positionAttribute->setCount(triangleCount * 3);
// Geometry
Qt3DRender::QGeometry* geometry = new Qt3DRender::QGeometry();
Qt3DCore::QGeometry* geometry = new Qt3DCore::QGeometry();
geometry->addAttribute(positionAttribute);
Qt3DRender::QGeometryRenderer* geometryRenderer = new Qt3DRender::QGeometryRenderer();
@@ -1698,7 +1687,7 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createWireframeWithoutObscuredEdgesMeshGeo
lines.erase(std::remove_if(lines.begin(), lines.end(), std::bind(&PDF3DSceneProcessor::isLineObscured, this, meshGeometry, std::placeholders::_1)), lines.end());
// Vertex buffer
Qt3DRender::QAttribute* positionAttribute = createPositionAttribute(meshGeometry->getPositions());
Qt3DCore::QAttribute* positionAttribute = createPositionAttribute(meshGeometry->getPositions());
// Index buffer
const uint32_t lineCount = static_cast<uint32_t>(lines.size());
@@ -1706,8 +1695,7 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createWireframeWithoutObscuredEdgesMeshGeo
indexBufferData.resize(lineCount * 2 * sizeof(unsigned int));
unsigned int* indexBufferDataPtr = reinterpret_cast<unsigned int*>(indexBufferData.data());
Qt3DRender::QBuffer* indexBuffer = new Qt3DRender::QBuffer();
indexBuffer->setType(Qt3DRender::QBuffer::IndexBuffer);
Qt3DCore::QBuffer* indexBuffer = new Qt3DCore::QBuffer();
for (const auto& line : lines)
{
@@ -1716,14 +1704,14 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createWireframeWithoutObscuredEdgesMeshGeo
}
indexBuffer->setData(indexBufferData);
Qt3DRender::QAttribute* indexAttribute = new Qt3DRender::QAttribute();
indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute);
indexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedInt);
Qt3DCore::QAttribute* indexAttribute = new Qt3DCore::QAttribute();
indexAttribute->setAttributeType(Qt3DCore::QAttribute::IndexAttribute);
indexAttribute->setVertexBaseType(Qt3DCore::QAttribute::UnsignedInt);
indexAttribute->setBuffer(indexBuffer);
indexAttribute->setCount(2 * lineCount);
// Geometry
Qt3DRender::QGeometry* geometry = new Qt3DRender::QGeometry();
Qt3DCore::QGeometry* geometry = new Qt3DCore::QGeometry();
geometry->addAttribute(positionAttribute);
geometry->addAttribute(indexAttribute);
@@ -1745,10 +1733,9 @@ Qt3DCore::QNode* PDF3DSceneProcessor::createWireframeWithoutObscuredEdgesMeshGeo
return entity;
}
Qt3DRender::QAttribute* PDF3DSceneProcessor::createGenericAttribute(const std::vector<QVector3D>& values) const
Qt3DCore::QAttribute* PDF3DSceneProcessor::createGenericAttribute(const std::vector<QVector3D>& values) const
{
Qt3DRender::QBuffer* vertexBuffer = new Qt3DRender::QBuffer();
vertexBuffer->setType(Qt3DRender::QBuffer::VertexBuffer);
Qt3DCore::QBuffer* vertexBuffer = new Qt3DCore::QBuffer();
uint positionCount = static_cast<uint>(values.size());
QByteArray vertexBufferData;
@@ -1764,10 +1751,10 @@ Qt3DRender::QAttribute* PDF3DSceneProcessor::createGenericAttribute(const std::v
}
vertexBuffer->setData(vertexBufferData);
Qt3DRender::QAttribute* positionAttribute = new Qt3DRender::QAttribute();
positionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float);
Qt3DCore::QAttribute* positionAttribute = new Qt3DCore::QAttribute();
positionAttribute->setVertexBaseType(Qt3DCore::QAttribute::Float);
positionAttribute->setVertexSize(3);
positionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
positionAttribute->setAttributeType(Qt3DCore::QAttribute::VertexAttribute);
positionAttribute->setBuffer(vertexBuffer);
positionAttribute->setByteOffset(0);
positionAttribute->setByteStride(3 * sizeof(float));
@@ -1776,24 +1763,24 @@ Qt3DRender::QAttribute* PDF3DSceneProcessor::createGenericAttribute(const std::v
return positionAttribute;
}
Qt3DRender::QAttribute* PDF3DSceneProcessor::createPositionAttribute(const std::vector<QVector3D>& positions) const
Qt3DCore::QAttribute* PDF3DSceneProcessor::createPositionAttribute(const std::vector<QVector3D>& positions) const
{
Qt3DRender::QAttribute* attribute = createGenericAttribute(positions);
attribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName());
Qt3DCore::QAttribute* attribute = createGenericAttribute(positions);
attribute->setName(Qt3DCore::QAttribute::defaultPositionAttributeName());
return attribute;
}
Qt3DRender::QAttribute* PDF3DSceneProcessor::createNormalAttribute(const std::vector<QVector3D>& normals) const
Qt3DCore::QAttribute* PDF3DSceneProcessor::createNormalAttribute(const std::vector<QVector3D>& normals) const
{
Qt3DRender::QAttribute* attribute = createGenericAttribute(normals);
attribute->setName(Qt3DRender::QAttribute::defaultNormalAttributeName());
Qt3DCore::QAttribute* attribute = createGenericAttribute(normals);
attribute->setName(Qt3DCore::QAttribute::defaultNormalAttributeName());
return attribute;
}
Qt3DRender::QAttribute* PDF3DSceneProcessor::createColorAttribute(const std::vector<QVector3D>& colors) const
Qt3DCore::QAttribute* PDF3DSceneProcessor::createColorAttribute(const std::vector<QVector3D>& colors) const
{
Qt3DRender::QAttribute* attribute = createGenericAttribute(colors);
attribute->setName(Qt3DRender::QAttribute::defaultColorAttributeName());
Qt3DCore::QAttribute* attribute = createGenericAttribute(colors);
attribute->setName(Qt3DCore::QAttribute::defaultColorAttributeName());
return attribute;
}

View File

@@ -31,12 +31,12 @@ namespace Qt3DCore
{
class QNode;
class QEntity;
class QAttribute;
}
namespace Qt3DRender
{
class QMaterial;
class QAttribute;
}
namespace pdf
@@ -140,10 +140,10 @@ private:
Qt3DCore::QNode* createSolidSingleColoredFaceGeometry(const pdf::u3d::PDF3D_U3D_MeshGeometry* meshGeometry);
Qt3DCore::QNode* createWireframeWithoutObscuredEdgesMeshGeometry(const pdf::u3d::PDF3D_U3D_MeshGeometry* meshGeometry);
Qt3DRender::QAttribute* createGenericAttribute(const std::vector<QVector3D>& values) const;
Qt3DRender::QAttribute* createPositionAttribute(const std::vector<QVector3D>& positions) const;
Qt3DRender::QAttribute* createNormalAttribute(const std::vector<QVector3D>& normals) const;
Qt3DRender::QAttribute* createColorAttribute(const std::vector<QVector3D>& colors) const;
Qt3DCore::QAttribute* createGenericAttribute(const std::vector<QVector3D>& values) const;
Qt3DCore::QAttribute* createPositionAttribute(const std::vector<QVector3D>& positions) const;
Qt3DCore::QAttribute* createNormalAttribute(const std::vector<QVector3D>& normals) const;
Qt3DCore::QAttribute* createColorAttribute(const std::vector<QVector3D>& colors) const;
Qt3DRender::QMaterial* createMaterialFromShader(const QString& shaderName, bool forceUseVertexColors, qreal opacity) const;

View File

@@ -218,14 +218,14 @@ void PDFMediaViewerDialog::initFrom3DAnnotation(const pdf::PDFDocument* document
pdf::PDFObject object = document->getObject(stream.getStream());
if (object.isStream())
{
QByteArray data = document->getDecodedStream(object.getStream());
QByteArray annotationData = document->getDecodedStream(object.getStream());
switch (stream.getType())
{
case pdf::PDF3DStream::Type::U3D:
{
QStringList errors;
m_sceneU3d = pdf::u3d::PDF3D_U3D::parse(data, &errors);
m_sceneU3d = pdf::u3d::PDF3D_U3D::parse(annotationData, &errors);
break;
}