diff --git a/common/camera.cpp b/common/camera.cpp index de4c9b2a..65d7ab0e 100644 --- a/common/camera.cpp +++ b/common/camera.cpp @@ -934,7 +934,7 @@ void lcCamera::BoxTest(lcObjectBoxTest& ObjectBoxTest) const if (lcBoundingBoxIntersectsVolume(Min, Max, LocalPlanes)) { - ObjectBoxTest.Objects.Add(const_cast(this)); + ObjectBoxTest.Objects.emplace_back(const_cast(this)); return; } @@ -952,7 +952,7 @@ void lcCamera::BoxTest(lcObjectBoxTest& ObjectBoxTest) const if (lcBoundingBoxIntersectsVolume(Min, Max, LocalPlanes)) { - ObjectBoxTest.Objects.Add(const_cast(this)); + ObjectBoxTest.Objects.emplace_back(const_cast(this)); return; } @@ -970,7 +970,7 @@ void lcCamera::BoxTest(lcObjectBoxTest& ObjectBoxTest) const if (lcBoundingBoxIntersectsVolume(Min, Max, LocalPlanes)) { - ObjectBoxTest.Objects.Add(const_cast(this)); + ObjectBoxTest.Objects.emplace_back(const_cast(this)); return; } } diff --git a/common/lc_array.h b/common/lc_array.h index 2afe5cda..991f3e3b 100644 --- a/common/lc_array.h +++ b/common/lc_array.h @@ -25,7 +25,7 @@ public: : lcArray((int)Init.size()) { for (const T& Element : Init) - Add(Element); + emplace_back(Element); } ~lcArray() @@ -112,17 +112,17 @@ public: return &mData[0] + mLength; } - bool IsEmpty() const + bool empty() const { return mLength == 0; } - int GetSize() const + int size() const { return mLength; } - void SetSize(size_t NewSize) + void resize(size_t NewSize) { if (NewSize > mAlloc) AllocGrow(NewSize - mLength); @@ -152,13 +152,13 @@ public: } } - void Add(const T& NewItem) + void emplace_back(const T& NewItem) { AllocGrow(1); mData[mLength++] = NewItem; } - T& Add() + T& emplace_back() { AllocGrow(1); mData[mLength++] = T(); diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index ead8da46..b5dc59c3 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -2173,7 +2173,7 @@ void lcMainWindow::CameraMenuAboutToShow() QAction* Action = mActions[ActionIdx]; int CameraIdx = ActionIdx - LC_VIEW_CAMERA_FIRST; - if (CameraIdx < Cameras.GetSize()) + if (CameraIdx < Cameras.size()) { if (CurrentCamera == Cameras[CameraIdx]) { @@ -2242,7 +2242,7 @@ void lcMainWindow::UpdateModels() QAction* Action = mActions[ActionIdx]; int ModelIdx = ActionIdx - LC_MODEL_FIRST; - if (ModelIdx < Models.GetSize()) + if (ModelIdx < Models.size()) { Action->setChecked(CurrentModel == Models[ModelIdx]); Action->setText(QString::fromLatin1("%1%2 %3").arg(ModelIdx < 9 ? QString("&") : QString(), QString::number(ModelIdx + 1), Models[ModelIdx]->GetProperties().mFileName)); @@ -2395,7 +2395,7 @@ void lcMainWindow::MergeProject() if (NewProject->Load(LoadFileName, true)) { - int NumModels = NewProject->GetModels().GetSize(); + int NumModels = NewProject->GetModels().size(); lcGetActiveProject()->Merge(NewProject); @@ -2461,7 +2461,7 @@ bool lcMainWindow::SaveProject(const QString& FileName) if (SaveFileName.isEmpty()) SaveFileName = QFileInfo(QDir(lcGetProfileString(LC_PROFILE_PROJECTS_PATH)), Project->GetTitle()).absoluteFilePath(); - QString Filter = (Project->GetModels().GetSize() > 1) ? tr("Supported Files (*.mpd);;All Files (*.*)") : tr("Supported Files (*.ldr *.dat *.mpd);;All Files (*.*)"); + QString Filter = (Project->GetModels().size() > 1) ? tr("Supported Files (*.mpd);;All Files (*.*)") : tr("Supported Files (*.ldr *.dat *.mpd);;All Files (*.*)"); SaveFileName = QFileDialog::getSaveFileName(this, tr("Save Model"), SaveFileName, Filter); diff --git a/common/lc_meshloader.cpp b/common/lc_meshloader.cpp index 21b23fd7..86f565a1 100644 --- a/common/lc_meshloader.cpp +++ b/common/lc_meshloader.cpp @@ -168,7 +168,7 @@ quint32 lcMeshLoaderTypeData::AddVertex(const lcVector3& Position, bool Optimize { if (Optimize) { - for (int VertexIdx = mVertices.GetSize() - 1; VertexIdx >= 0; VertexIdx--) + for (int VertexIdx = mVertices.size() - 1; VertexIdx >= 0; VertexIdx--) { const lcMeshLoaderVertex& Vertex = mVertices[VertexIdx]; @@ -177,20 +177,20 @@ quint32 lcMeshLoaderTypeData::AddVertex(const lcVector3& Position, bool Optimize } } - lcMeshLoaderVertex& Vertex = mVertices.Add(); + lcMeshLoaderVertex& Vertex = mVertices.emplace_back(); Vertex.Position = Position; Vertex.Normal = lcVector3(0.0f, 0.0f, 0.0f); Vertex.NormalWeight = 0.0f; - return mVertices.GetSize() - 1; + return mVertices.size() - 1; } quint32 lcMeshLoaderTypeData::AddVertex(const lcVector3& Position, const lcVector3& Normal, float NormalWeight, bool Optimize) { if (Optimize) { - for (int VertexIdx = mVertices.GetSize() - 1; VertexIdx >= 0; VertexIdx--) + for (int VertexIdx = mVertices.size() - 1; VertexIdx >= 0; VertexIdx--) { lcMeshLoaderVertex& Vertex = mVertices[VertexIdx]; @@ -212,25 +212,25 @@ quint32 lcMeshLoaderTypeData::AddVertex(const lcVector3& Position, const lcVecto } } - lcMeshLoaderVertex& Vertex = mVertices.Add(); + lcMeshLoaderVertex& Vertex = mVertices.emplace_back(); Vertex.Position = Position; Vertex.Normal = Normal; Vertex.NormalWeight = 1.0f; - return mVertices.GetSize() - 1; + return mVertices.size() - 1; } quint32 lcMeshLoaderTypeData::AddConditionalVertex(const lcVector3(&Position)[4]) { - lcMeshLoaderConditionalVertex& Vertex = mConditionalVertices.Add(); + lcMeshLoaderConditionalVertex& Vertex = mConditionalVertices.emplace_back(); Vertex.Position[0] = Position[0]; Vertex.Position[1] = Position[1]; Vertex.Position[2] = Position[2]; Vertex.Position[3] = Position[3]; - return mConditionalVertices.GetSize() - 1; + return mConditionalVertices.size() - 1; } void lcMeshLoaderTypeData::ProcessLine(int LineType, lcMeshLoaderMaterial* Material, bool WindingCCW, lcVector3 (&Vertices)[4], bool Optimize) @@ -277,15 +277,15 @@ void lcMeshLoaderTypeData::ProcessLine(int LineType, lcMeshLoaderMaterial* Mater { if (WindingCCW) { - Section->mIndices.Add(Indices[0]); - Section->mIndices.Add(Indices[1]); - Section->mIndices.Add(Indices[2]); + Section->mIndices.emplace_back(Indices[0]); + Section->mIndices.emplace_back(Indices[1]); + Section->mIndices.emplace_back(Indices[2]); } else { - Section->mIndices.Add(Indices[2]); - Section->mIndices.Add(Indices[1]); - Section->mIndices.Add(Indices[0]); + Section->mIndices.emplace_back(Indices[2]); + Section->mIndices.emplace_back(Indices[1]); + Section->mIndices.emplace_back(Indices[0]); } } } @@ -299,8 +299,8 @@ void lcMeshLoaderTypeData::ProcessLine(int LineType, lcMeshLoaderMaterial* Mater if (Indices[0] != Indices[1]) { - Section->mIndices.Add(Indices[0]); - Section->mIndices.Add(Indices[1]); + Section->mIndices.emplace_back(Indices[0]); + Section->mIndices.emplace_back(Indices[1]); } } else if (LineType == 5) @@ -308,22 +308,22 @@ void lcMeshLoaderTypeData::ProcessLine(int LineType, lcMeshLoaderMaterial* Mater int Indices[2]; Indices[0] = AddConditionalVertex(Vertices); - Section->mIndices.Add(Indices[0]); + Section->mIndices.emplace_back(Indices[0]); std::swap(Vertices[0], Vertices[1]); Indices[1] = AddConditionalVertex(Vertices); - Section->mIndices.Add(Indices[1]); + Section->mIndices.emplace_back(Indices[1]); } } void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const lcMatrix44& Transform, quint32 CurrentColorCode, bool InvertWinding, bool InvertNormals, lcMeshLoaderTextureMap* TextureMap) { const lcArray& DataVertices = Data.mVertices; - lcArray IndexRemap(DataVertices.GetSize()); + lcArray IndexRemap(DataVertices.size()); const lcMatrix33 NormalTransform = lcMatrix33Transpose(lcMatrix33(lcMatrix44Inverse(Transform))); - mVertices.AllocGrow(DataVertices.GetSize()); + mVertices.AllocGrow(DataVertices.size()); for (const lcMeshLoaderVertex& DataVertex : DataVertices) { @@ -340,11 +340,11 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l Index = AddVertex(Position, Normal, DataVertex.NormalWeight, true); } - IndexRemap.Add(Index); + IndexRemap.emplace_back(Index); } - mConditionalVertices.AllocGrow(Data.mConditionalVertices.GetSize()); - lcArray ConditionalRemap(Data.mConditionalVertices.GetSize()); + mConditionalVertices.AllocGrow(Data.mConditionalVertices.size()); + lcArray ConditionalRemap(Data.mConditionalVertices.size()); for (const lcMeshLoaderConditionalVertex& DataVertex : Data.mConditionalVertices) { @@ -356,7 +356,7 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l Position[3] = lcMul31(DataVertex.Position[3], Transform); const int Index = AddConditionalVertex(Position); - ConditionalRemap.Add(Index); + ConditionalRemap.emplace_back(Index); } for (const std::unique_ptr& SrcSection : Data.mSections) @@ -385,25 +385,25 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l DstSection = AddSection(PrimitiveType, mMeshData->GetMaterial(ColorCode)); } - DstSection->mIndices.AllocGrow(SrcSection->mIndices.GetSize()); + DstSection->mIndices.AllocGrow(SrcSection->mIndices.size()); if (PrimitiveType == LC_MESH_CONDITIONAL_LINES) { for (const quint32 Index : SrcSection->mIndices) - DstSection->mIndices.Add(ConditionalRemap[Index]); + DstSection->mIndices.emplace_back(ConditionalRemap[Index]); } else if (!InvertWinding || (PrimitiveType == LC_MESH_LINES)) { for (const quint32 Index : SrcSection->mIndices) - DstSection->mIndices.Add(IndexRemap[Index]); + DstSection->mIndices.emplace_back(IndexRemap[Index]); } else { - for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.GetSize(); IndexIdx += 3) + for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx += 3) { - DstSection->mIndices.Add(IndexRemap[SrcSection->mIndices[IndexIdx + 2]]); - DstSection->mIndices.Add(IndexRemap[SrcSection->mIndices[IndexIdx + 1]]); - DstSection->mIndices.Add(IndexRemap[SrcSection->mIndices[IndexIdx + 0]]); + DstSection->mIndices.emplace_back(IndexRemap[SrcSection->mIndices[IndexIdx + 2]]); + DstSection->mIndices.emplace_back(IndexRemap[SrcSection->mIndices[IndexIdx + 1]]); + DstSection->mIndices.emplace_back(IndexRemap[SrcSection->mIndices[IndexIdx + 0]]); } } } @@ -415,15 +415,15 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat quint32 BaseIndex; const lcMatrix33 NormalTransform = lcMatrix33Transpose(lcMatrix33(lcMatrix44Inverse(Transform))); - BaseIndex = mVertices.GetSize(); + BaseIndex = mVertices.size(); - mVertices.SetGrow(lcMin(mVertices.GetSize(), 8 * 1024 * 1024)); - mVertices.AllocGrow(DataVertices.GetSize()); + mVertices.SetGrow(lcMin(mVertices.size(), 8 * 1024 * 1024)); + mVertices.AllocGrow(DataVertices.size()); - for (int SrcVertexIdx = 0; SrcVertexIdx < DataVertices.GetSize(); SrcVertexIdx++) + for (int SrcVertexIdx = 0; SrcVertexIdx < DataVertices.size(); SrcVertexIdx++) { const lcMeshLoaderVertex& SrcVertex = DataVertices[SrcVertexIdx]; - lcMeshLoaderVertex& DstVertex = mVertices.Add(); + lcMeshLoaderVertex& DstVertex = mVertices.emplace_back(); DstVertex.Position = lcMul31(SrcVertex.Position, Transform); DstVertex.Normal = lcNormalize(lcMul(SrcVertex.Normal, NormalTransform)); if (InvertNormals) @@ -431,12 +431,12 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat DstVertex.NormalWeight = SrcVertex.NormalWeight; } - mConditionalVertices.AllocGrow(Data.mConditionalVertices.GetSize()); - const quint32 BaseConditional = mConditionalVertices.GetSize(); + mConditionalVertices.AllocGrow(Data.mConditionalVertices.size()); + const quint32 BaseConditional = mConditionalVertices.size(); for (const lcMeshLoaderConditionalVertex& DataVertex : Data.mConditionalVertices) { - lcMeshLoaderConditionalVertex& Vertex = mConditionalVertices.Add(); + lcMeshLoaderConditionalVertex& Vertex = mConditionalVertices.emplace_back(); Vertex.Position[0] = lcMul31(DataVertex.Position[0], Transform); Vertex.Position[1] = lcMul31(DataVertex.Position[1], Transform); @@ -470,26 +470,26 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat DstSection = AddSection(PrimitiveType, mMeshData->GetMaterial(ColorCode)); } - DstSection->mIndices.SetGrow(lcMin(DstSection->mIndices.GetSize(), 8 * 1024 * 1024)); - DstSection->mIndices.AllocGrow(SrcSection->mIndices.GetSize()); + DstSection->mIndices.SetGrow(lcMin(DstSection->mIndices.size(), 8 * 1024 * 1024)); + DstSection->mIndices.AllocGrow(SrcSection->mIndices.size()); if (PrimitiveType == LC_MESH_CONDITIONAL_LINES) { for (const quint32 Index : SrcSection->mIndices) - DstSection->mIndices.Add(BaseConditional + Index); + DstSection->mIndices.emplace_back(BaseConditional + Index); } else if (!InvertWinding || (PrimitiveType == LC_MESH_LINES)) { for (const quint32 Index : SrcSection->mIndices) - DstSection->mIndices.Add(BaseIndex + Index); + DstSection->mIndices.emplace_back(BaseIndex + Index); } else { - for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.GetSize(); IndexIdx += 3) + for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx += 3) { - DstSection->mIndices.Add(BaseIndex + SrcSection->mIndices[IndexIdx + 2]); - DstSection->mIndices.Add(BaseIndex + SrcSection->mIndices[IndexIdx + 1]); - DstSection->mIndices.Add(BaseIndex + SrcSection->mIndices[IndexIdx + 0]); + DstSection->mIndices.emplace_back(BaseIndex + SrcSection->mIndices[IndexIdx + 2]); + DstSection->mIndices.emplace_back(BaseIndex + SrcSection->mIndices[IndexIdx + 1]); + DstSection->mIndices.emplace_back(BaseIndex + SrcSection->mIndices[IndexIdx + 0]); } } } @@ -498,9 +498,9 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat void lcLibraryMeshData::AddVertices(lcMeshDataType MeshDataType, int VertexCount, int* BaseVertex, lcMeshLoaderVertex** VertexBuffer) { lcArray& Vertices = mData[MeshDataType].mVertices; - int CurrentSize = Vertices.GetSize(); + int CurrentSize = Vertices.size(); - Vertices.SetSize(CurrentSize + VertexCount); + Vertices.resize(CurrentSize + VertexCount); *BaseVertex = CurrentSize; *VertexBuffer = &Vertices[CurrentSize]; @@ -510,9 +510,9 @@ void lcLibraryMeshData::AddIndices(lcMeshDataType MeshDataType, lcMeshPrimitiveT { lcMeshLoaderSection* Section = mData[MeshDataType].AddSection(PrimitiveType, GetMaterial(ColorCode)); lcArray& Indices = Section->mIndices; - const int CurrentSize = Indices.GetSize(); + const int CurrentSize = Indices.size(); - Indices.SetSize(CurrentSize + IndexCount); + Indices.resize(CurrentSize + IndexCount); *IndexBuffer = &Indices[CurrentSize]; } @@ -631,7 +631,7 @@ static bool lcMeshLoaderFinalSectionCompare(const lcMeshLoaderFinalSection& a, c quint32 lcLibraryMeshData::AddTexturedVertex(const lcVector3& Position, const lcVector3& Normal, const lcVector2& TexCoords) { - for (int VertexIndex = mTexturedVertices.GetSize() - 1; VertexIndex >= 0; VertexIndex--) + for (int VertexIndex = mTexturedVertices.size() - 1; VertexIndex >= 0; VertexIndex--) { const lcMeshLoaderTexturedVertex& Vertex = mTexturedVertices[VertexIndex]; @@ -639,13 +639,13 @@ quint32 lcLibraryMeshData::AddTexturedVertex(const lcVector3& Position, const lc return VertexIndex; } - lcMeshLoaderTexturedVertex& Vertex = mTexturedVertices.Add(); + lcMeshLoaderTexturedVertex& Vertex = mTexturedVertices.emplace_back(); Vertex.Position = Position; Vertex.Normal = Normal; Vertex.TexCoords = TexCoords; - return mTexturedVertices.GetSize() - 1; + return mTexturedVertices.size() - 1; } void lcLibraryMeshData::GeneratePlanarTexcoords(lcMeshLoaderSection* Section, const lcMeshLoaderTypeData& Data) @@ -688,7 +688,7 @@ void lcLibraryMeshData::GenerateCylindricalTexcoords(lcMeshLoaderSection* Sectio const lcVector4 Plane2 = lcVector4(Plane2Normal, -lcDot(Plane2Normal, Material->Points[1])); const float Angle = 360.0f / Material->Angles[0]; - for (int TriangleIndex = 0; TriangleIndex < Section->mIndices.GetSize(); TriangleIndex += 3) + for (int TriangleIndex = 0; TriangleIndex < Section->mIndices.size(); TriangleIndex += 3) { const lcVector3 Positions[3] = { @@ -731,7 +731,7 @@ void lcLibraryMeshData::GenerateSphericalTexcoords(lcMeshLoaderSection* Section, const float Angle1 = 360.0f / Material->Angles[0]; const float Angle2 = 180.0f / Material->Angles[1]; - for (int TriangleIndex = 0; TriangleIndex < Section->mIndices.GetSize(); TriangleIndex += 3) + for (int TriangleIndex = 0; TriangleIndex < Section->mIndices.size(); TriangleIndex += 3) { const lcVector3 Positions[3] = { @@ -808,9 +808,9 @@ lcMesh* lcLibraryMeshData::CreateMesh() for (int MeshDataIdx = 0; MeshDataIdx < LC_NUM_MESHDATA_TYPES; MeshDataIdx++) { BaseVertices[MeshDataIdx] = NumVertices; - NumVertices += mData[MeshDataIdx].mVertices.GetSize(); + NumVertices += mData[MeshDataIdx].mVertices.size(); BaseConditionalVertices[MeshDataIdx] = ConditionalVertexCount; - ConditionalVertexCount += mData[MeshDataIdx].mConditionalVertices.GetSize(); + ConditionalVertexCount += mData[MeshDataIdx].mConditionalVertices.size(); } if (mHasTextures) @@ -829,7 +829,7 @@ lcMesh* lcLibraryMeshData::CreateMesh() if (FinalSection.PrimitiveType == Section->mPrimitiveType && FinalSection.Color == Section->mMaterial->Color && !strcmp(FinalSection.Name, Section->mMaterial->Name)) return; - lcMeshLoaderFinalSection& FinalSection = FinalSections.Add(); + lcMeshLoaderFinalSection& FinalSection = FinalSections.emplace_back(); FinalSection.PrimitiveType = Section->mPrimitiveType; FinalSection.Color = Section->mMaterial->Color; @@ -838,23 +838,23 @@ lcMesh* lcLibraryMeshData::CreateMesh() for (const std::unique_ptr& Section : mData[LC_MESHDATA_SHARED].mSections) { - NumIndices += Section->mIndices.GetSize(); + NumIndices += Section->mIndices.size(); AddFinalSection(Section.get(), FinalSections[LodIdx]); } for (const std::unique_ptr& Section : mData[LodIdx].mSections) { - NumIndices += Section->mIndices.GetSize(); + NumIndices += Section->mIndices.size(); AddFinalSection(Section.get(), FinalSections[LodIdx]); } - NumSections[LodIdx] = FinalSections[LodIdx].GetSize(); + NumSections[LodIdx] = FinalSections[LodIdx].size(); std::sort(FinalSections[LodIdx].begin(), FinalSections[LodIdx].end(), lcMeshLoaderFinalSectionCompare); } - Mesh->Create(NumSections, NumVertices, mTexturedVertices.GetSize(), ConditionalVertexCount, NumIndices); + Mesh->Create(NumSections, NumVertices, mTexturedVertices.size(), ConditionalVertexCount, NumIndices); lcVertex* DstVerts = (lcVertex*)Mesh->mVertexData; @@ -918,7 +918,7 @@ void lcLibraryMeshData::WriteSections(lcMesh* Mesh, const lcArraymLods[LodIdx].Sections[SectionIdx]; @@ -953,7 +953,7 @@ void lcLibraryMeshData::WriteSections(lcMesh* Mesh, const lcArraymIndices.GetSize(); IndexIdx++) + for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx++) *Index++ = BaseVertex + SrcSection->mIndices[IndexIdx]; } break; @@ -962,14 +962,14 @@ void lcLibraryMeshData::WriteSections(lcMesh* Mesh, const lcArraymIndices.GetSize(); IndexIdx++) + for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx++) *Index++ = BaseVertex + SrcSection->mIndices[IndexIdx]; } break; case LC_MESH_TEXTURED_TRIANGLES: { - for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.GetSize(); IndexIdx++) + for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.size(); IndexIdx++) *Index++ = SrcSection->mIndices[IndexIdx]; } break; @@ -978,7 +978,7 @@ void lcLibraryMeshData::WriteSections(lcMesh* Mesh, const lcArraymIndices.GetSize(); + DstSection.NumIndices += SrcSection->mIndices.size(); }; for (const std::unique_ptr& Section : mData[LC_MESHDATA_SHARED].mSections) diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 05f07cb5..e59246df 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -317,7 +317,7 @@ void lcModel::UpdatePieceInfo(std::vector& UpdatedModels) const lcMesh* Mesh = mPieceInfo->GetMesh(); - if (mPieces.IsEmpty() && !Mesh) + if (mPieces.empty() && !Mesh) { mPieceInfo->SetBoundingBox(lcVector3(0.0f, 0.0f, 0.0f), lcVector3(0.0f, 0.0f, 0.0f)); return; @@ -405,7 +405,7 @@ void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly, lcStep LastStep) if (PieceGroup) { - if (CurrentGroups.IsEmpty() || (!CurrentGroups.IsEmpty() && PieceGroup != CurrentGroups[CurrentGroups.GetSize() - 1])) + if (CurrentGroups.empty() || (!CurrentGroups.empty() && PieceGroup != CurrentGroups[CurrentGroups.size() - 1])) { lcArray PieceParents; @@ -414,14 +414,14 @@ void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly, lcStep LastStep) int FoundParent = -1; - while (!CurrentGroups.IsEmpty()) + while (!CurrentGroups.empty()) { - lcGroup* Group = CurrentGroups[CurrentGroups.GetSize() - 1]; + lcGroup* Group = CurrentGroups[CurrentGroups.size() - 1]; const int Index = PieceParents.FindIndex(Group); if (Index == -1) { - CurrentGroups.RemoveIndex(CurrentGroups.GetSize() - 1); + CurrentGroups.RemoveIndex(CurrentGroups.size() - 1); Stream << QLatin1String("0 !LEOCAD GROUP END\r\n"); } else @@ -431,19 +431,19 @@ void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly, lcStep LastStep) } } - for (int ParentIdx = FoundParent + 1; ParentIdx < PieceParents.GetSize(); ParentIdx++) + for (int ParentIdx = FoundParent + 1; ParentIdx < PieceParents.size(); ParentIdx++) { lcGroup* Group = PieceParents[ParentIdx]; - CurrentGroups.Add(Group); + CurrentGroups.emplace_back(Group); Stream << QLatin1String("0 !LEOCAD GROUP BEGIN ") << Group->mName << LineEnding; } } } else { - while (CurrentGroups.GetSize()) + while (CurrentGroups.size()) { - CurrentGroups.RemoveIndex(CurrentGroups.GetSize() - 1); + CurrentGroups.RemoveIndex(CurrentGroups.size() - 1); Stream << QLatin1String("0 !LEOCAD GROUP END\r\n"); } } @@ -495,9 +495,9 @@ void lcModel::SaveLDraw(QTextStream& Stream, bool SelectedOnly, lcStep LastStep) CurrentLine++; } - while (CurrentGroups.GetSize()) + while (CurrentGroups.size()) { - CurrentGroups.RemoveIndex(CurrentGroups.GetSize() - 1); + CurrentGroups.RemoveIndex(CurrentGroups.size() - 1); Stream << QLatin1String("0 !LEOCAD GROUP END\r\n"); } @@ -643,7 +643,7 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project) if (Camera->ParseLDrawLine(LineStream)) { Camera->CreateName(mCameras); - mCameras.Add(Camera); + mCameras.emplace_back(Camera); Camera = nullptr; } } @@ -655,7 +655,7 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project) if (Light->ParseLDrawLine(LineStream)) { Light->CreateName(mLights); - mLights.Add(Light); + mLights.emplace_back(Light); Light = nullptr; } } @@ -671,16 +671,16 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project) { QString Name = LineStream.readAll().trimmed(); lcGroup* Group = GetGroup(Name, true); - if (!CurrentGroups.IsEmpty()) - Group->mGroup = CurrentGroups[CurrentGroups.GetSize() - 1]; + if (!CurrentGroups.empty()) + Group->mGroup = CurrentGroups[CurrentGroups.size() - 1]; else Group->mGroup = nullptr; - CurrentGroups.Add(Group); + CurrentGroups.emplace_back(Group); } else if (Token == QLatin1String("END")) { - if (!CurrentGroups.IsEmpty()) - CurrentGroups.RemoveIndex(CurrentGroups.GetSize() - 1); + if (!CurrentGroups.empty()) + CurrentGroups.RemoveIndex(CurrentGroups.size() - 1); } } else if (Token == QLatin1String("SYNTH")) @@ -739,8 +739,8 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project) if (!Piece) Piece = new lcPiece(nullptr); - if (!CurrentGroups.IsEmpty()) - Piece->SetGroup(CurrentGroups[CurrentGroups.GetSize() - 1]); + if (!CurrentGroups.empty()) + Piece->SetGroup(CurrentGroups[CurrentGroups.size() - 1]); PieceInfo* Info = Library->FindPiece(PartId.toLatin1().constData(), Project, true, true); @@ -835,7 +835,7 @@ bool lcModel::LoadBinary(lcFile* file) file->ReadS32(&count, 1); lcPiecesLibrary* Library = lcGetPiecesLibrary(); - const int FirstNewPiece = mPieces.GetSize(); + const int FirstNewPiece = mPieces.size(); while (count--) { @@ -919,13 +919,13 @@ bool lcModel::LoadBinary(lcFile* file) if (fv >= 0.5f) { - const int NumGroups = mGroups.GetSize(); + const int NumGroups = mGroups.size(); file->ReadS32(&count, 1); for (i = 0; i < count; i++) - mGroups.Add(new lcGroup()); + mGroups.emplace_back(new lcGroup()); - for (int GroupIdx = NumGroups; GroupIdx < mGroups.GetSize(); GroupIdx++) + for (int GroupIdx = NumGroups; GroupIdx < mGroups.size(); GroupIdx++) { lcGroup* Group = mGroups[GroupIdx]; @@ -941,7 +941,7 @@ bool lcModel::LoadBinary(lcFile* file) Group->FileLoad(file); } - for (int GroupIdx = NumGroups; GroupIdx < mGroups.GetSize(); GroupIdx++) + for (int GroupIdx = NumGroups; GroupIdx < mGroups.size(); GroupIdx++) { lcGroup* Group = mGroups[GroupIdx]; @@ -954,7 +954,7 @@ bool lcModel::LoadBinary(lcFile* file) Group->mGroup = mGroups[NumGroups + i]; } - for (int PieceIdx = FirstNewPiece; PieceIdx < mPieces.GetSize(); PieceIdx++) + for (int PieceIdx = FirstNewPiece; PieceIdx < mPieces.size(); PieceIdx++) { lcPiece* Piece = mPieces[PieceIdx]; @@ -1092,7 +1092,7 @@ bool lcModel::LoadInventory(const QByteArray& Inventory) } } - if (mPieces.IsEmpty()) + if (mPieces.empty()) return false; Library->WaitForLoadQueue(); @@ -1139,7 +1139,7 @@ bool lcModel::LoadInventory(const QByteArray& Inventory) void lcModel::Merge(lcModel* Other) { - for (int PieceIdx = 0; PieceIdx < Other->mPieces.GetSize(); PieceIdx++) + for (int PieceIdx = 0; PieceIdx < Other->mPieces.size(); PieceIdx++) { lcPiece* Piece = Other->mPieces[PieceIdx]; Piece->SetFileLine(-1); @@ -1148,29 +1148,29 @@ void lcModel::Merge(lcModel* Other) Other->mPieces.RemoveAll(); - for (int CameraIdx = 0; CameraIdx < Other->mCameras.GetSize(); CameraIdx++) + for (int CameraIdx = 0; CameraIdx < Other->mCameras.size(); CameraIdx++) { lcCamera* Camera = Other->mCameras[CameraIdx]; Camera->CreateName(mCameras); - mCameras.Add(Camera); + mCameras.emplace_back(Camera); } Other->mCameras.RemoveAll(); - for (int LightIdx = 0; LightIdx < Other->mLights.GetSize(); LightIdx++) + for (int LightIdx = 0; LightIdx < Other->mLights.size(); LightIdx++) { lcLight* Light = Other->mLights[LightIdx]; Light->CreateName(mLights); - mLights.Add(Light); + mLights.emplace_back(Light); } Other->mLights.RemoveAll(); - for (int GroupIdx = 0; GroupIdx < Other->mGroups.GetSize(); GroupIdx++) + for (int GroupIdx = 0; GroupIdx < Other->mGroups.size(); GroupIdx++) { lcGroup* Group = Other->mGroups[GroupIdx]; Group->CreateName(mGroups); - mGroups.Add(Group); + mGroups.emplace_back(Group); } Other->mGroups.RemoveAll(); @@ -1215,8 +1215,8 @@ void lcModel::Paste(bool PasteToCurrentStep) Model->LoadLDraw(Buffer, lcGetActiveProject()); const lcArray& PastedPieces = Model->mPieces; - lcArray SelectedObjects; - SelectedObjects.AllocGrow(PastedPieces.GetSize()); + std::vector SelectedObjects; + SelectedObjects.reserve(PastedPieces.size()); for (lcPiece* Piece : PastedPieces) { @@ -1225,19 +1225,19 @@ void lcModel::Paste(bool PasteToCurrentStep) if (PasteToCurrentStep) { Piece->SetStepShow(mCurrentStep); - SelectedObjects.Add(Piece); + SelectedObjects.emplace_back(Piece); } else { if (Piece->GetStepShow() <= mCurrentStep) - SelectedObjects.Add(Piece); + SelectedObjects.emplace_back(Piece); } } Merge(Model); SaveCheckpoint(tr("Pasting")); - if (SelectedObjects.GetSize() == 1) + if (SelectedObjects.size() == 1) ClearSelectionAndSetFocus(SelectedObjects[0], LC_PIECE_SECTION_POSITION, false); else SetSelectionAndFocus(SelectedObjects, nullptr, 0, false); @@ -1249,7 +1249,7 @@ void lcModel::Paste(bool PasteToCurrentStep) void lcModel::DuplicateSelectedPieces() { - lcArray NewPieces; + std::vector NewPieces; lcPiece* Focus = nullptr; std::map GroupMap; @@ -1281,7 +1281,7 @@ void lcModel::DuplicateSelectedPieces() } }; - for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++) + for (int PieceIdx = 0; PieceIdx < mPieces.size(); PieceIdx++) { lcPiece* Piece = mPieces[PieceIdx]; @@ -1290,7 +1290,7 @@ void lcModel::DuplicateSelectedPieces() lcPiece* NewPiece = new lcPiece(*Piece); NewPiece->UpdatePosition(mCurrentStep); - NewPieces.Add(NewPiece); + NewPieces.emplace_back(NewPiece); if (Piece->IsFocused()) Focus = NewPiece; @@ -1303,7 +1303,7 @@ void lcModel::DuplicateSelectedPieces() Piece->SetGroup(GetNewGroup(Group)); } - if (NewPieces.IsEmpty()) + if (NewPieces.empty()) return; gMainWindow->UpdateTimeline(false, false); @@ -1909,7 +1909,7 @@ void lcModel::RemoveStep(lcStep Step) lcGroup* lcModel::AddGroup(const QString& Prefix, lcGroup* Parent) { lcGroup* Group = new lcGroup(); - mGroups.Add(Group); + mGroups.emplace_back(Group); Group->mName = GetGroupName(Prefix); Group->mGroup = Parent; @@ -1927,7 +1927,7 @@ lcGroup* lcModel::GetGroup(const QString& Name, bool CreateIfMissing) { lcGroup* Group = new lcGroup(); Group->mName = Name; - mGroups.Add(Group); + mGroups.emplace_back(Group); return Group; } @@ -1984,7 +1984,7 @@ void lcModel::UngroupSelection() if (SelectedGroups.FindIndex(Group) == -1) { mGroups.Remove(Group); - SelectedGroups.Add(Group); + SelectedGroups.emplace_back(Group); } } } @@ -2128,7 +2128,7 @@ void lcModel::RemoveEmptyGroups() { Removed = false; - for (int GroupIdx = 0; GroupIdx < mGroups.GetSize();) + for (int GroupIdx = 0; GroupIdx < mGroups.size();) { lcGroup* Group = mGroups[GroupIdx]; int Ref = 0; @@ -2137,7 +2137,7 @@ void lcModel::RemoveEmptyGroups() if (Piece->GetGroup() == Group) Ref++; - for (int ParentIdx = 0; ParentIdx < mGroups.GetSize(); ParentIdx++) + for (int ParentIdx = 0; ParentIdx < mGroups.size(); ParentIdx++) if (mGroups[ParentIdx]->mGroup == Group) Ref++; @@ -2158,7 +2158,7 @@ void lcModel::RemoveEmptyGroups() } } - for (int ParentIdx = 0; ParentIdx < mGroups.GetSize(); ParentIdx++) + for (int ParentIdx = 0; ParentIdx < mGroups.size(); ParentIdx++) { if (mGroups[ParentIdx]->mGroup == Group) { @@ -2265,7 +2265,7 @@ void lcModel::AddPiece() if (!CurPiece) return; - lcPiece* Last = mPieces.IsEmpty() ? nullptr : mPieces[mPieces.GetSize() - 1]; + lcPiece* Last = mPieces.empty() ? nullptr : mPieces[mPieces.size() - 1]; for (lcPiece* Piece : mPieces) { @@ -2305,7 +2305,7 @@ void lcModel::AddPiece() void lcModel::AddPiece(lcPiece* Piece) { - for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++) + for (int PieceIdx = 0; PieceIdx < mPieces.size(); PieceIdx++) { if (mPieces[PieceIdx]->GetStepShow() > Piece->GetStepShow()) { @@ -2314,7 +2314,7 @@ void lcModel::AddPiece(lcPiece* Piece) } } - InsertPiece(Piece, mPieces.GetSize()); + InsertPiece(Piece, mPieces.size()); } void lcModel::InsertPiece(lcPiece* Piece, int Index) @@ -2334,7 +2334,7 @@ void lcModel::InsertPiece(lcPiece* Piece, int Index) void lcModel::DeleteAllCameras() { - if (mCameras.IsEmpty()) + if (mCameras.empty()) return; mCameras.DeleteAll(); @@ -2423,9 +2423,9 @@ void lcModel::RemoveFocusedControlPoint() void lcModel::ShowSelectedPiecesEarlier() { - lcArray MovedPieces; + std::vector MovedPieces; - for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); ) + for (int PieceIdx = 0; PieceIdx < mPieces.size(); ) { lcPiece* Piece = mPieces[PieceIdx]; @@ -2438,7 +2438,7 @@ void lcModel::ShowSelectedPiecesEarlier() Step--; Piece->SetStepShow(Step); - MovedPieces.Add(Piece); + MovedPieces.emplace_back(Piece); mPieces.RemoveIndex(PieceIdx); continue; } @@ -2447,12 +2447,11 @@ void lcModel::ShowSelectedPiecesEarlier() PieceIdx++; } - if (MovedPieces.IsEmpty()) + if (MovedPieces.empty()) return; - for (int PieceIdx = 0; PieceIdx < MovedPieces.GetSize(); PieceIdx++) + for (lcPiece* Piece : MovedPieces) { - lcPiece* Piece = MovedPieces[PieceIdx]; Piece->SetFileLine(-1); AddPiece(Piece); } @@ -2467,7 +2466,7 @@ void lcModel::ShowSelectedPiecesLater() { lcArray MovedPieces; - for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); ) + for (int PieceIdx = 0; PieceIdx < mPieces.size(); ) { lcPiece* Piece = mPieces[PieceIdx]; @@ -2483,7 +2482,7 @@ void lcModel::ShowSelectedPiecesLater() if (!Piece->IsVisible(mCurrentStep)) Piece->SetSelected(false); - MovedPieces.Add(Piece); + MovedPieces.emplace_back(Piece); mPieces.RemoveIndex(PieceIdx); continue; } @@ -2492,10 +2491,10 @@ void lcModel::ShowSelectedPiecesLater() PieceIdx++; } - if (MovedPieces.IsEmpty()) + if (MovedPieces.empty()) return; - for (int PieceIdx = 0; PieceIdx < MovedPieces.GetSize(); PieceIdx++) + for (int PieceIdx = 0; PieceIdx < MovedPieces.size(); PieceIdx++) { lcPiece* Piece = MovedPieces[PieceIdx]; Piece->SetFileLine(-1); @@ -2510,7 +2509,7 @@ void lcModel::ShowSelectedPiecesLater() void lcModel::SetPieceSteps(const QList>& PieceSteps) { - if (PieceSteps.size() != mPieces.GetSize()) + if (PieceSteps.size() != mPieces.size()) return; bool Modified = false; @@ -2561,7 +2560,7 @@ void lcModel::MoveSelectionToModel(lcModel* Model) lcStep FirstStep = LC_STEP_MAX; lcVector3 Min(FLT_MAX, FLT_MAX, FLT_MAX), Max(-FLT_MAX, -FLT_MAX, -FLT_MAX); - for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); ) + for (int PieceIdx = 0; PieceIdx < mPieces.size(); ) { lcPiece* Piece = mPieces[PieceIdx]; @@ -2570,7 +2569,7 @@ void lcModel::MoveSelectionToModel(lcModel* Model) Piece->CompareBoundingBox(Min, Max); mPieces.RemoveIndex(PieceIdx); Piece->SetGroup(nullptr); // todo: copy groups - Pieces.Add(Piece); + Pieces.emplace_back(Piece); FirstStep = qMin(FirstStep, Piece->GetStepShow()); if (!ModelPiece) @@ -2588,7 +2587,7 @@ void lcModel::MoveSelectionToModel(lcModel* Model) lcVector3 ModelCenter = (Min + Max) / 2.0f; ModelCenter.z += (Min.z - Max.z) / 2.0f; - for (int PieceIdx = 0; PieceIdx < Pieces.GetSize(); PieceIdx++) + for (int PieceIdx = 0; PieceIdx < Pieces.size(); PieceIdx++) { lcPiece* Piece = Pieces[PieceIdx]; Piece->SetFileLine(-1); @@ -2612,9 +2611,9 @@ void lcModel::MoveSelectionToModel(lcModel* Model) void lcModel::InlineSelectedModels() { - lcArray NewPieces; + std::vector NewPieces; - for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); ) + for (int PieceIdx = 0; PieceIdx < mPieces.size(); ) { lcPiece* Piece = mPieces[PieceIdx]; @@ -2644,7 +2643,7 @@ void lcModel::InlineSelectedModels() NewPiece->SetColorIndex(ColorIndex); NewPiece->UpdatePosition(mCurrentStep); - NewPieces.Add(NewPiece); + NewPieces.emplace_back(NewPiece); InsertPiece(NewPiece, PieceIdx); PieceIdx++; } @@ -2652,7 +2651,7 @@ void lcModel::InlineSelectedModels() delete Piece; } - if (!NewPieces.GetSize()) + if (!NewPieces.size()) { QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("No models selected.")); return; @@ -2669,7 +2668,7 @@ bool lcModel::RemoveSelectedObjects() bool RemovedCamera = false; bool RemovedLight = false; - for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); ) + for (int PieceIdx = 0; PieceIdx < mPieces.size(); ) { lcPiece* Piece = mPieces[PieceIdx]; @@ -2683,7 +2682,7 @@ bool lcModel::RemoveSelectedObjects() PieceIdx++; } - for (int CameraIdx = 0; CameraIdx < mCameras.GetSize(); ) + for (int CameraIdx = 0; CameraIdx < mCameras.size(); ) { lcCamera* Camera = mCameras[CameraIdx]; @@ -2703,7 +2702,7 @@ bool lcModel::RemoveSelectedObjects() CameraIdx++; } - for (int LightIdx = 0; LightIdx < mLights.GetSize(); ) + for (int LightIdx = 0; LightIdx < mLights.size(); ) { lcLight* Light = mLights[LightIdx]; @@ -3035,7 +3034,7 @@ void lcModel::SetSelectedPiecesStepShow(lcStep Step) lcArray MovedPieces; bool SelectionChanged = false; - for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); ) + for (int PieceIdx = 0; PieceIdx < mPieces.size(); ) { lcPiece* Piece = mPieces[PieceIdx]; @@ -3049,7 +3048,7 @@ void lcModel::SetSelectedPiecesStepShow(lcStep Step) SelectionChanged = true; } - MovedPieces.Add(Piece); + MovedPieces.emplace_back(Piece); mPieces.RemoveIndex(PieceIdx); continue; } @@ -3057,10 +3056,10 @@ void lcModel::SetSelectedPiecesStepShow(lcStep Step) PieceIdx++; } - if (MovedPieces.IsEmpty()) + if (MovedPieces.empty()) return; - for (int PieceIdx = 0; PieceIdx < MovedPieces.GetSize(); PieceIdx++) + for (int PieceIdx = 0; PieceIdx < MovedPieces.size(); PieceIdx++) { lcPiece* Piece = MovedPieces[PieceIdx]; Piece->SetFileLine(-1); @@ -3241,7 +3240,7 @@ void lcModel::GetSubModels(lcArray& SubModels) const { lcModel* SubModel = Piece->mPieceInfo->GetModel(); if (SubModels.FindIndex(SubModel) == -1) - SubModels.Add(SubModel); + SubModels.emplace_back(SubModel); } } } @@ -3463,7 +3462,7 @@ lcBoundingBox lcModel::GetAllPiecesBoundingBox() const { lcBoundingBox Box; - if (!mPieces.IsEmpty()) + if (!mPieces.empty()) { Box.Min = lcVector3(FLT_MAX, FLT_MAX, FLT_MAX); Box.Max = lcVector3(-FLT_MAX, -FLT_MAX, -FLT_MAX); @@ -3549,7 +3548,7 @@ void lcModel::GetSelectionInformation(int* Flags, std::vector& Select *Flags = 0; *Focus = nullptr; - if (mPieces.IsEmpty()) + if (mPieces.empty()) *Flags |= LC_SEL_NO_PIECES; else { @@ -3637,11 +3636,11 @@ void lcModel::GetSelectionInformation(int* Flags, std::vector& Select } } -lcArray lcModel::GetSelectionModePieces(const lcPiece* SelectedPiece) const +std::vector lcModel::GetSelectionModePieces(const lcPiece* SelectedPiece) const { const PieceInfo* Info = SelectedPiece->mPieceInfo; const int ColorIndex = SelectedPiece->GetColorIndex(); - lcArray Pieces; + std::vector Pieces; switch (gMainWindow->GetSelectionMode()) { @@ -3651,19 +3650,19 @@ lcArray lcModel::GetSelectionModePieces(const lcPiece* SelectedPiece) case lcSelectionMode::Piece: for (lcPiece* Piece : mPieces) if (Piece->IsVisible(mCurrentStep) && Piece->mPieceInfo == Info && Piece != SelectedPiece) - Pieces.Add(Piece); + Pieces.emplace_back(Piece); break; case lcSelectionMode::Color: for (lcPiece* Piece : mPieces) if (Piece->IsVisible(mCurrentStep) && Piece->GetColorIndex() == ColorIndex && Piece != SelectedPiece) - Pieces.Add(Piece); + Pieces.emplace_back(Piece); break; case lcSelectionMode::PieceColor: for (lcPiece* Piece : mPieces) if (Piece->IsVisible(mCurrentStep) && Piece->mPieceInfo == Info && Piece->GetColorIndex() == ColorIndex && Piece != SelectedPiece) - Pieces.Add(Piece); + Pieces.emplace_back(Piece); break; } @@ -3728,7 +3727,7 @@ void lcModel::FocusOrDeselectObject(const lcObjectSection& ObjectSection) SelectGroup(Piece->GetTopGroup(), IsSelected); else { - lcArray Pieces = GetSelectionModePieces(Piece); + std::vector Pieces = GetSelectionModePieces(Piece); AddToSelection(Pieces, false, false); } } @@ -3757,7 +3756,7 @@ void lcModel::ClearSelectionAndSetFocus(lcObject* Object, quint32 Section, bool if (EnableSelectionMode) { - lcArray Pieces = GetSelectionModePieces((lcPiece*)Object); + std::vector Pieces = GetSelectionModePieces((lcPiece*)Object); AddToSelection(Pieces, false, false); } } @@ -3772,7 +3771,7 @@ void lcModel::ClearSelectionAndSetFocus(const lcObjectSection& ObjectSection, bo ClearSelectionAndSetFocus(ObjectSection.Object, ObjectSection.Section, EnableSelectionMode); } -void lcModel::SetSelectionAndFocus(const lcArray& Selection, lcObject* Focus, quint32 Section, bool EnableSelectionMode) +void lcModel::SetSelectionAndFocus(const std::vector& Selection, lcObject* Focus, quint32 Section, bool EnableSelectionMode) { ClearSelection(false); @@ -3786,7 +3785,7 @@ void lcModel::SetSelectionAndFocus(const lcArray& Selection, lcObject if (EnableSelectionMode) { - lcArray Pieces = GetSelectionModePieces((lcPiece*)Focus); + std::vector Pieces = GetSelectionModePieces((lcPiece*)Focus); AddToSelection(Pieces, false, false); } } @@ -3795,7 +3794,7 @@ void lcModel::SetSelectionAndFocus(const lcArray& Selection, lcObject AddToSelection(Selection, EnableSelectionMode, true); } -void lcModel::AddToSelection(const lcArray& Objects, bool EnableSelectionMode, bool UpdateInterface) +void lcModel::AddToSelection(const std::vector& Objects, bool EnableSelectionMode, bool UpdateInterface) { for (lcObject* Object : Objects) { @@ -3809,7 +3808,7 @@ void lcModel::AddToSelection(const lcArray& Objects, bool EnableSelec if (EnableSelectionMode) { - lcArray Pieces = GetSelectionModePieces((lcPiece*)Object); + std::vector Pieces = GetSelectionModePieces((lcPiece*)Object); AddToSelection(Pieces, false, false); } } @@ -3822,7 +3821,7 @@ void lcModel::AddToSelection(const lcArray& Objects, bool EnableSelec } } -void lcModel::RemoveFromSelection(const lcArray& Objects) +void lcModel::RemoveFromSelection(const std::vector& Objects) { for (lcObject* SelectedObject : Objects) { @@ -3837,7 +3836,7 @@ void lcModel::RemoveFromSelection(const lcArray& Objects) SelectGroup(Piece->GetTopGroup(), false); else { - lcArray Pieces = GetSelectionModePieces(Piece); + std::vector Pieces = GetSelectionModePieces(Piece); for (lcObject* Object : Pieces) { @@ -3878,7 +3877,7 @@ void lcModel::RemoveFromSelection(const lcObjectSection& ObjectSection) SelectGroup(Piece->GetTopGroup(), false); else { - lcArray Pieces = GetSelectionModePieces(Piece); + std::vector Pieces = GetSelectionModePieces(Piece); for (lcObject* Object : Pieces) { @@ -4011,7 +4010,7 @@ void lcModel::UnhideAllPieces() void lcModel::FindReplacePiece(bool SearchForward, bool FindAll, bool Replace) { - if (mPieces.IsEmpty()) + if (mPieces.empty()) return; const lcFindReplaceParams& Params = lcView::GetFindReplaceParams(); @@ -4042,7 +4041,7 @@ void lcModel::FindReplacePiece(bool SearchForward, bool FindAll, bool Replace) Piece->SetPieceInfo(Params.ReplacePieceInfo, QString(), true); }; - int StartIdx = mPieces.GetSize() - 1; + int StartIdx = mPieces.size() - 1; int ReplacedCount = 0; if (!FindAll) @@ -4052,7 +4051,7 @@ void lcModel::FindReplacePiece(bool SearchForward, bool FindAll, bool Replace) if (FocusedPiece) { - for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++) + for (int PieceIdx = 0; PieceIdx < mPieces.size(); PieceIdx++) { if (FocusedPiece == mPieces[PieceIdx]) { @@ -4071,7 +4070,7 @@ void lcModel::FindReplacePiece(bool SearchForward, bool FindAll, bool Replace) int CurrentIdx = StartIdx; lcPiece* Focus = nullptr; - lcArray Selection; + std::vector Selection; for (;;) { @@ -4081,8 +4080,8 @@ void lcModel::FindReplacePiece(bool SearchForward, bool FindAll, bool Replace) CurrentIdx--; if (CurrentIdx < 0) - CurrentIdx = mPieces.GetSize() - 1; - else if (CurrentIdx >= mPieces.GetSize()) + CurrentIdx = mPieces.size() - 1; + else if (CurrentIdx >= mPieces.size()) CurrentIdx = 0; lcPiece* Current = mPieces[CurrentIdx]; @@ -4091,7 +4090,7 @@ void lcModel::FindReplacePiece(bool SearchForward, bool FindAll, bool Replace) { if (FindAll) { - Selection.Add(Current); + Selection.emplace_back(Current); if (Replacing) { ReplacePiece(Current); @@ -4243,7 +4242,7 @@ void lcModel::InsertLightToolClicked(const lcVector3& Position, lcLightType Ligh { lcLight* Light = new lcLight(Position, LightType); Light->CreateName(mLights); - mLights.Add(Light); + mLights.emplace_back(Light); ClearSelectionAndSetFocus(Light, LC_LIGHT_SECTION_POSITION, false); @@ -4274,7 +4273,7 @@ void lcModel::BeginCameraTool(const lcVector3& Position, const lcVector3& Target { lcCamera* Camera = new lcCamera(Position[0], Position[1], Position[2], Target[0], Target[1], Target[2]); Camera->CreateName(mCameras); - mCameras.Add(Camera); + mCameras.emplace_back(Camera); mMouseToolDistance = Position; mMouseToolFirstMove = false; @@ -4284,7 +4283,7 @@ void lcModel::BeginCameraTool(const lcVector3& Position, const lcVector3& Target void lcModel::UpdateCameraTool(const lcVector3& Position) { - lcCamera* Camera = mCameras[mCameras.GetSize() - 1]; + lcCamera* Camera = mCameras[mCameras.size() - 1]; Camera->MoveSelected(1, false, Position - mMouseToolDistance); Camera->UpdatePosition(1); @@ -4541,7 +4540,7 @@ void lcModel::ShowPropertiesDialog() void lcModel::ShowSelectByNameDialog() { - if (mPieces.IsEmpty() && mCameras.IsEmpty() && mLights.IsEmpty()) + if (mPieces.empty() && mCameras.empty() && mLights.empty()) { QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("Nothing to select.")); return; @@ -4576,7 +4575,7 @@ void lcModel::ShowArrayDialog() return; } - lcArray NewPieces; + std::vector NewPieces; for (int Step1 = 0; Step1 < Dialog.mCounts[0]; Step1++) { @@ -4611,13 +4610,13 @@ void lcModel::ShowArrayDialog() NewPiece->Initialize(ModelWorld, mCurrentStep); NewPiece->SetColorIndex(Piece->GetColorIndex()); - NewPieces.Add(NewPiece); + NewPieces.emplace_back(NewPiece); } } } } - for (int PieceIdx = 0; PieceIdx < NewPieces.GetSize(); PieceIdx++) + for (size_t PieceIdx = 0; PieceIdx < NewPieces.size(); PieceIdx++) { lcPiece* Piece = (lcPiece*)NewPieces[PieceIdx]; Piece->UpdatePosition(mCurrentStep); @@ -4639,7 +4638,8 @@ void lcModel::ShowMinifigDialog() gMainWindow->GetActiveView()->MakeCurrent(); lcGroup* Group = AddGroup(tr("Minifig #"), nullptr); - lcArray Pieces(LC_MFW_NUMITEMS); + std::vector Pieces; + Pieces.reserve(LC_MFW_NUMITEMS); lcMinifig& Minifig = Dialog.mMinifigWizard->mMinifig; for (int PartIdx = 0; PartIdx < LC_MFW_NUMITEMS; PartIdx++) @@ -4655,7 +4655,7 @@ void lcModel::ShowMinifigDialog() AddPiece(Piece); Piece->UpdatePosition(mCurrentStep); - Pieces.Add(Piece); + Pieces.emplace_back(Piece); } SetSelectionAndFocus(Pieces, nullptr, 0, false); @@ -4667,7 +4667,8 @@ void lcModel::SetMinifig(const lcMinifig& Minifig) { DeleteModel(); - lcArray Pieces(LC_MFW_NUMITEMS); + std::vector Pieces; + Pieces.reserve(LC_MFW_NUMITEMS); for (int PartIdx = 0; PartIdx < LC_MFW_NUMITEMS; PartIdx++) { @@ -4681,7 +4682,7 @@ void lcModel::SetMinifig(const lcMinifig& Minifig) AddPiece(Piece); Piece->UpdatePosition(1); - Pieces.Add(Piece); + Pieces.emplace_back(Piece); } SetSelectionAndFocus(Pieces, nullptr, 0, false); diff --git a/common/lc_model.h b/common/lc_model.h index 73874350..8f98dee1 100644 --- a/common/lc_model.h +++ b/common/lc_model.h @@ -275,7 +275,7 @@ public: bool HasPieces() const { - return !mPieces.IsEmpty(); + return !mPieces.empty(); } bool AnyPiecesSelected() const; @@ -296,15 +296,15 @@ public: void GetPartsListForStep(lcStep Step, int DefaultColorIndex, lcPartsList& PartsList, bool Cumulative) const; void GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, std::vector& ModelParts) const; void GetSelectionInformation(int* Flags, std::vector& Selection, lcObject** Focus) const; - lcArray GetSelectionModePieces(const lcPiece* SelectedPiece) const; + std::vector GetSelectionModePieces(const lcPiece* SelectedPiece) const; void FocusOrDeselectObject(const lcObjectSection& ObjectSection); void ClearSelection(bool UpdateInterface); void ClearSelectionAndSetFocus(lcObject* Object, quint32 Section, bool EnableSelectionMode); void ClearSelectionAndSetFocus(const lcObjectSection& ObjectSection, bool EnableSelectionMode); - void SetSelectionAndFocus(const lcArray& Selection, lcObject* Focus, quint32 Section, bool EnableSelectionMode); - void AddToSelection(const lcArray& Objects, bool EnableSelectionMode, bool UpdateInterface); - void RemoveFromSelection(const lcArray& Objects); + void SetSelectionAndFocus(const std::vector& Selection, lcObject* Focus, quint32 Section, bool EnableSelectionMode); + void AddToSelection(const std::vector& Objects, bool EnableSelectionMode, bool UpdateInterface); + void RemoveFromSelection(const std::vector& Objects); void RemoveFromSelection(const lcObjectSection& ObjectSection); void SelectAllPieces(); void InvertSelection(); diff --git a/common/lc_partselectionwidget.cpp b/common/lc_partselectionwidget.cpp index e020b399..ef27cca0 100644 --- a/common/lc_partselectionwidget.cpp +++ b/common/lc_partselectionwidget.cpp @@ -179,7 +179,7 @@ void lcPartSelectionListModel::SetModelsCategory() const lcArray& Models = lcGetActiveProject()->GetModels(); lcModel* ActiveModel = gMainWindow->GetActiveModel(); - for (int ModelIdx = 0; ModelIdx < Models.GetSize(); ModelIdx++) + for (int ModelIdx = 0; ModelIdx < Models.size(); ModelIdx++) { lcModel* Model = Models[ModelIdx]; diff --git a/common/lc_previewwidget.cpp b/common/lc_previewwidget.cpp index 496b3521..29061020 100644 --- a/common/lc_previewwidget.cpp +++ b/common/lc_previewwidget.cpp @@ -57,7 +57,7 @@ void lcPreviewDockWidget::UpdatePreview() void lcPreviewDockWidget::ClearPreview() { - if (mPreview->GetModel()->GetPieces().GetSize()) + if (mPreview->GetModel()->GetPieces().size()) mPreview->ClearPreview(); mLabel->setText(QString()); @@ -67,7 +67,7 @@ void lcPreviewDockWidget::SetPreviewLock() { bool Locked = mLockAction->isChecked(); - if (Locked && mPreview->GetModel()->GetPieces().IsEmpty()) + if (Locked && mPreview->GetModel()->GetPieces().empty()) { mLockAction->setChecked(false); return; diff --git a/common/lc_synth.cpp b/common/lc_synth.cpp index 596e5f52..e421ccb4 100644 --- a/common/lc_synth.cpp +++ b/common/lc_synth.cpp @@ -665,7 +665,7 @@ void lcSynthInfoCurved::CalculateSections(const std::vector float SectionLength = 0.0f; - for (quint32 ControlPointIndex = 0; ControlPointIndex < ControlPoints.size() - 1 && Sections.GetSize() < mNumSections + 2; ControlPointIndex++) + for (quint32 ControlPointIndex = 0; ControlPointIndex < ControlPoints.size() - 1 && Sections.size() < mNumSections + 2; ControlPointIndex++) { lcVector3 SegmentControlPoints[4]; @@ -683,7 +683,7 @@ void lcSynthInfoCurved::CalculateSections(const std::vector else SectionLength = mStart.Length; - Sections.Add(StartTransform); + Sections.emplace_back(StartTransform); } EndTransform = lcMatrix44(lcMul(lcMul(lcMatrix33(mEnd.Transform), lcMatrix33(EndTransform)), lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f))), EndTransform.GetTranslation()); @@ -703,20 +703,20 @@ void lcSynthInfoCurved::CalculateSections(const std::vector float it = 1.0f - t; lcVector3 Position = it * it * it * SegmentControlPoints[0] + it * it * 3.0f * t * SegmentControlPoints[1] + it * 3.0 * t * t * SegmentControlPoints[2] + t * t * t * SegmentControlPoints[3]; - CurvePoints.Add(Position); + CurvePoints.emplace_back(Position); } float CurrentSegmentLength = 0.0f; float TotalSegmentLength = 0.0f; - for (int PointIdx = 0; PointIdx < CurvePoints.GetSize() - 1; PointIdx++) + for (int PointIdx = 0; PointIdx < CurvePoints.size() - 1; PointIdx++) TotalSegmentLength += lcLength(CurvePoints[PointIdx] - CurvePoints[PointIdx + 1]); lcVector3 StartUp = lcMul30(lcVector3(1.0f, 0.0f, 0.0f), StartTransform); float Twist = GetSectionTwist(StartTransform, EndTransform); int CurrentPointIndex = 0; - while (CurrentPointIndex < CurvePoints.GetSize() - 1) + while (CurrentPointIndex < CurvePoints.size() - 1) { float Length = lcLength(CurvePoints[CurrentPointIndex + 1] - CurvePoints[CurrentPointIndex]); CurrentSegmentLength += Length; @@ -744,41 +744,41 @@ void lcSynthInfoCurved::CalculateSections(const std::vector Up = lcNormalize(lcCross(Side, Tangent)); StartUp = Up; - Sections.Add(lcMatrix44(lcMatrix33(Up, Tangent, Side), CurvePoints[CurrentPointIndex])); + Sections.emplace_back(lcMatrix44(lcMatrix33(Up, Tangent, Side), CurvePoints[CurrentPointIndex])); if (SectionCallback) SectionCallback(CurvePoints[CurrentPointIndex], ControlPointIndex, t); - if (Sections.GetSize() == mNumSections + 2) + if (Sections.size() == mNumSections + 2) break; - if (mCenterLength != 0.0f && (Sections.GetSize() == mNumSections / 2 + 1)) + if (mCenterLength != 0.0f && (Sections.size() == mNumSections / 2 + 1)) SectionLength += mCenterLength; else SectionLength += mMiddle.Length; - if (Sections.GetSize() == mNumSections + 1 && !mRigidEdges) + if (Sections.size() == mNumSections + 1 && !mRigidEdges) SectionLength += mEnd.Length; } } - while (Sections.GetSize() < mNumSections + 2) + while (Sections.size() < mNumSections + 2) { lcMatrix44 EndTransform = lcMatrix44LeoCADToLDraw(ControlPoints.back().Transform); EndTransform = lcMatrix44(lcMul(lcMul(lcMatrix33(mEnd.Transform), lcMatrix33(EndTransform)), lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f))), EndTransform.GetTranslation()); lcVector3 Position = lcMul31(lcVector3(0.0f, SectionLength, 0.0f), EndTransform); EndTransform.SetTranslation(Position); - Sections.Add(EndTransform); + Sections.emplace_back(EndTransform); if (SectionCallback) SectionCallback(Position, static_cast(ControlPoints.size()) - 1, 1.0f); - if (mCenterLength != 0.0f && (Sections.GetSize() == mNumSections / 2 + 1)) + if (mCenterLength != 0.0f && (Sections.size() == mNumSections / 2 + 1)) SectionLength += mCenterLength; else SectionLength += mMiddle.Length; - if (Sections.GetSize() == mNumSections + 1 && !mRigidEdges) + if (Sections.size() == mNumSections + 1 && !mRigidEdges) SectionLength += mEnd.Length; } } @@ -790,7 +790,7 @@ void lcSynthInfoBraidedString::CalculateSections(const std::vector(ControlPoints.size()) - 1, 1.0f); - if (mCenterLength != 0.0f && (Sections.GetSize() == mNumSections / 2 + 1)) + if (mCenterLength != 0.0f && (Sections.size() == mNumSections / 2 + 1)) SectionLength += mCenterLength; else SectionLength += mMiddle.Length; - if (Sections.GetSize() == mNumSections + 1 && !mRigidEdges) + if (Sections.size() == mNumSections + 1 && !mRigidEdges) SectionLength += mEnd.Length; } } @@ -913,7 +913,7 @@ void lcSynthInfoStraight::CalculateSections(const std::vector& SectionsIn) const { lcArray Sections; - Sections.SetSize(SectionsIn.GetSize()); + Sections.resize(SectionsIn.size()); - for (int SectionIdx = 0; SectionIdx < Sections.GetSize(); SectionIdx++) + for (int SectionIdx = 0; SectionIdx < Sections.size(); SectionIdx++) { lcMatrix33 Transform(lcMul(lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f)), lcMatrix33(SectionsIn[SectionIdx]))); lcVector3 Offset = SectionsIn[SectionIdx].GetTranslation(); @@ -1333,22 +1333,22 @@ void lcSynthInfoBraidedString::AddParts(lcMemFile& File, lcLibraryMeshData& Mesh int BaseVertex; lcMeshLoaderVertex* VertexBuffer; quint32* IndexBuffer; - MeshData.AddVertices(LC_MESHDATA_SHARED, NumBraids * ((Sections.GetSize() - 2) * NumSegments + 1), &BaseVertex, &VertexBuffer); - MeshData.AddIndices(LC_MESHDATA_SHARED, LC_MESH_LINES, 24, NumBraids * (Sections.GetSize() - 2) * NumSegments * 2, &IndexBuffer); + MeshData.AddVertices(LC_MESHDATA_SHARED, NumBraids * ((Sections.size() - 2) * NumSegments + 1), &BaseVertex, &VertexBuffer); + MeshData.AddIndices(LC_MESHDATA_SHARED, LC_MESH_LINES, 24, NumBraids * (Sections.size() - 2) * NumSegments * 2, &IndexBuffer); for (int BraidIdx = 0; BraidIdx < NumBraids; BraidIdx++) { int BaseX = (BraidIdx == 0 || BraidIdx == 2) ? 0 : 8; int BaseY = (BraidIdx == 0 || BraidIdx == 3) ? 12 : 4; - for (int SectionIdx = 1; SectionIdx < Sections.GetSize() - 1; SectionIdx++) + for (int SectionIdx = 1; SectionIdx < Sections.size() - 1; SectionIdx++) { lcMatrix33 Transform1 = lcMatrix33(Sections[SectionIdx]); lcMatrix33 Transform2 = lcMatrix33(Sections[SectionIdx + 1]); lcVector3 Offset1 = Sections[SectionIdx].GetTranslation(); lcVector3 Offset2 = Sections[SectionIdx + 1].GetTranslation(); - for (int SegmentIdx = 0; SegmentIdx < ((SectionIdx < Sections.GetSize() - 2) ? NumSegments : NumSegments + 1); SegmentIdx++) + for (int SegmentIdx = 0; SegmentIdx < ((SectionIdx < Sections.size() - 2) ? NumSegments : NumSegments + 1); SegmentIdx++) { float t = (float)SegmentIdx / (float)NumSegments; @@ -1375,17 +1375,17 @@ void lcSynthInfoBraidedString::AddParts(lcMemFile& File, lcLibraryMeshData& Mesh } int NumSlices = 16; - MeshData.AddVertices(LC_MESHDATA_SHARED, NumSlices * ((Sections.GetSize() - 2) * NumSegments + 1), &BaseVertex, &VertexBuffer); - MeshData.AddIndices(LC_MESHDATA_SHARED, LC_MESH_TRIANGLES, 16, NumSlices * (Sections.GetSize() - 2) * NumSegments * 6, &IndexBuffer); + MeshData.AddVertices(LC_MESHDATA_SHARED, NumSlices * ((Sections.size() - 2) * NumSegments + 1), &BaseVertex, &VertexBuffer); + MeshData.AddIndices(LC_MESHDATA_SHARED, LC_MESH_TRIANGLES, 16, NumSlices * (Sections.size() - 2) * NumSegments * 6, &IndexBuffer); - for (int SectionIdx = 1; SectionIdx < Sections.GetSize() - 1; SectionIdx++) + for (int SectionIdx = 1; SectionIdx < Sections.size() - 1; SectionIdx++) { lcMatrix33 Transform1 = lcMatrix33(Sections[SectionIdx]); lcMatrix33 Transform2 = lcMatrix33(Sections[SectionIdx + 1]); lcVector3 Offset1 = Sections[SectionIdx].GetTranslation(); lcVector3 Offset2 = Sections[SectionIdx + 1].GetTranslation(); - for (int SegmentIdx = 0; SegmentIdx < ((SectionIdx < Sections.GetSize() - 2) ? NumSegments : NumSegments + 1); SegmentIdx++) + for (int SegmentIdx = 0; SegmentIdx < ((SectionIdx < Sections.size() - 2) ? NumSegments : NumSegments + 1); SegmentIdx++) { float t1 = (float)SegmentIdx / (float)NumSegments; int BaseX = 8; @@ -1420,7 +1420,7 @@ void lcSynthInfoBraidedString::AddParts(lcMemFile& File, lcLibraryMeshData& Mesh } { - const int SectionIdx = Sections.GetSize() - 1; + const int SectionIdx = Sections.size() - 1; lcMatrix33 Transform(Sections[SectionIdx]); lcVector3 Offset = lcMul31(lcVector3(8.0f, 0.0f, 0.0f), Sections[SectionIdx]); diff --git a/common/lc_timelinewidget.cpp b/common/lc_timelinewidget.cpp index cf66c699..963c407e 100644 --- a/common/lc_timelinewidget.cpp +++ b/common/lc_timelinewidget.cpp @@ -523,7 +523,7 @@ void lcTimelineWidget::CurrentItemChanged(QTreeWidgetItem* Current, QTreeWidgetI void lcTimelineWidget::ItemSelectionChanged() { - lcArray Selection; + std::vector Selection; lcStep LastStep = 1; QList SelectedItems = selectedItems(); @@ -533,23 +533,26 @@ void lcTimelineWidget::ItemSelectionChanged() if (Piece) { LastStep = lcMax(LastStep, Piece->GetStepShow()); - Selection.Add(Piece); + Selection.emplace_back(Piece); } } lcPiece* CurrentPiece = nullptr; QTreeWidgetItem* CurrentItem = currentItem(); + if (CurrentItem && CurrentItem->isSelected()) CurrentPiece = (lcPiece*)CurrentItem->data(0, Qt::UserRole).value(); bool Blocked = blockSignals(true); mIgnoreUpdates = true; lcModel* Model = gMainWindow->GetActiveModel(); + if (LastStep > Model->GetCurrentStep()) { Model->SetCurrentStep(LastStep); UpdateCurrentStepItem(); } + Model->SetSelectionAndFocus(Selection, CurrentPiece, LC_PIECE_SECTION_POSITION, false); mIgnoreUpdates = false; blockSignals(Blocked); diff --git a/common/lc_view.cpp b/common/lc_view.cpp index 747c11a3..393848de 100644 --- a/common/lc_view.cpp +++ b/common/lc_view.cpp @@ -586,7 +586,7 @@ lcPieceInfoRayTest lcView::FindPieceInfoUnderPointer(bool IgnoreSelected) const return ObjectRayTest.PieceInfoRayTest; } -lcArray lcView::FindObjectsInBox(float x1, float y1, float x2, float y2) const +std::vector lcView::FindObjectsInBox(float x1, float y1, float x2, float y2) const { float Left, Top, Bottom, Right; @@ -1772,7 +1772,7 @@ void lcView::SetCamera(const QString& CameraName) { const lcArray& Cameras = mModel->GetCameras(); - for (int CameraIdx = 0; CameraIdx < Cameras.GetSize(); CameraIdx++) + for (int CameraIdx = 0; CameraIdx < Cameras.size(); CameraIdx++) { if (CameraName.compare(Cameras[CameraIdx]->GetName(), Qt::CaseInsensitive) == 0) { @@ -1786,7 +1786,7 @@ void lcView::SetCameraIndex(int Index) { const lcArray& Cameras = mModel->GetCameras(); - if (Index >= Cameras.GetSize()) + if (Index >= Cameras.size()) return; lcCamera* Camera = Cameras[Index]; @@ -2334,7 +2334,7 @@ void lcView::StopTracking(bool Accept) case lcTool::Select: if (Accept && mMouseDownX != mMouseX && mMouseDownY != mMouseY) { - lcArray Objects = FindObjectsInBox(mMouseDownX, mMouseDownY, mMouseX, mMouseY); + std::vector Objects = FindObjectsInBox(mMouseDownX, mMouseDownY, mMouseX, mMouseY); if (mMouseModifiers & Qt::ControlModifier) ActiveModel->AddToSelection(Objects, true, true); diff --git a/common/lc_view.h b/common/lc_view.h index 7d040066..2c66a726 100644 --- a/common/lc_view.h +++ b/common/lc_view.h @@ -264,7 +264,7 @@ public: void GetRayUnderPointer(lcVector3& Start, lcVector3& End) const; lcObjectSection FindObjectUnderPointer(bool PiecesOnly, bool IgnoreSelected) const; lcPieceInfoRayTest FindPieceInfoUnderPointer(bool IgnoreSelected) const; - lcArray FindObjectsInBox(float x1, float y1, float x2, float y2) const; + std::vector FindObjectsInBox(float x1, float y1, float x2, float y2) const; lcVector3 ProjectPoint(const lcVector3& Point) const; lcVector3 UnprojectPoint(const lcVector3& Point) const; diff --git a/common/light.cpp b/common/light.cpp index 9708254e..80719974 100644 --- a/common/light.cpp +++ b/common/light.cpp @@ -393,7 +393,7 @@ void lcLight::BoxTest(lcObjectBoxTest& ObjectBoxTest) const if (lcDot3(mWorldMatrix.GetTranslation(), ObjectBoxTest.Planes[PlaneIdx]) + ObjectBoxTest.Planes[PlaneIdx][3] > LC_LIGHT_SPHERE_RADIUS) return; - ObjectBoxTest.Objects.Add(const_cast(this)); + ObjectBoxTest.Objects.emplace_back(const_cast(this)); return; } @@ -410,7 +410,7 @@ void lcLight::BoxTest(lcObjectBoxTest& ObjectBoxTest) const if (lcBoundingBoxIntersectsVolume(Min, Max, LocalPlanes)) { - ObjectBoxTest.Objects.Add(const_cast(this)); + ObjectBoxTest.Objects.emplace_back(const_cast(this)); return; } } diff --git a/common/object.h b/common/object.h index 7308ca0f..8452bd23 100644 --- a/common/object.h +++ b/common/object.h @@ -40,7 +40,7 @@ struct lcObjectBoxTest { lcCamera* ViewCamera; lcVector4 Planes[6]; - lcArray Objects; + std::vector Objects; }; #define LC_OBJECT_TRANSFORM_MOVE_X 0x001 diff --git a/common/piece.cpp b/common/piece.cpp index 0f3ac800..d3b26e30 100644 --- a/common/piece.cpp +++ b/common/piece.cpp @@ -515,7 +515,7 @@ void lcPiece::RayTest(lcObjectRayTest& ObjectRayTest) const void lcPiece::BoxTest(lcObjectBoxTest& ObjectBoxTest) const { if (mPieceInfo->BoxTest(mModelWorld, ObjectBoxTest.Planes)) - ObjectBoxTest.Objects.Add(const_cast(this)); + ObjectBoxTest.Objects.emplace_back(const_cast(this)); } void lcPiece::DrawInterface(lcContext* Context, const lcScene& Scene) const diff --git a/common/project.cpp b/common/project.cpp index cce62927..701213df 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -70,7 +70,7 @@ Project::Project(bool IsPreview) mActiveModel = new lcModel(tr(mIsPreview ? "Preview.ldr" : "New Model.ldr"), this, mIsPreview); mActiveModel->CreatePieceInfo(this); mActiveModel->SetSaved(); - mModels.Add(mActiveModel); + mModels.emplace_back(mActiveModel); if (!mIsPreview && gMainWindow) QObject::connect(&mFileWatcher, SIGNAL(fileChanged(const QString&)), gMainWindow, SLOT(ProjectFileChanged(const QString&))); @@ -95,7 +95,7 @@ bool Project::IsModified() const if (mModified) return true; - for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++) + for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++) if (mModels[ModelIdx]->IsModified()) return true; @@ -107,7 +107,7 @@ QString Project::GetTitle() const if (!mFileName.isEmpty()) return QFileInfo(mFileName).fileName(); - return mModels.GetSize() == 1 ? tr("New Model.ldr") : tr("New Model.mpd"); + return mModels.size() == 1 ? tr("New Model.ldr") : tr("New Model.mpd"); } QString Project::GetImageFileName(bool AllowCurrentFolder) const @@ -137,16 +137,16 @@ QString Project::GetImageFileName(bool AllowCurrentFolder) const void Project::SetActiveModel(int ModelIndex) { - if (ModelIndex < 0 || ModelIndex >= mModels.GetSize()) + if (ModelIndex < 0 || ModelIndex >= mModels.size()) return; - for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++) + for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++) mModels[ModelIdx]->SetActive(ModelIdx == ModelIndex); std::vector UpdatedModels; - UpdatedModels.reserve(mModels.GetSize()); + UpdatedModels.reserve(mModels.size()); - for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++) + for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++) mModels[ModelIdx]->UpdatePieceInfo(UpdatedModels); mActiveModel = mModels[ModelIndex]; @@ -160,7 +160,7 @@ void Project::SetActiveModel(int ModelIndex) void Project::SetActiveModel(const QString& FileName) { - for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++) + for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++) { if (FileName.compare(mModels[ModelIdx]->GetFileName(), Qt::CaseInsensitive) == 0) { @@ -241,7 +241,7 @@ lcModel* Project::CreateNewModel(bool ShowModel) { QStringList ModelNames; - for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++) + for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++) ModelNames.append(mModels[ModelIdx]->GetProperties().mFileName); QString Name = GetNewModelName(gMainWindow, tr("New Submodel"), QString(), ModelNames); @@ -253,11 +253,11 @@ lcModel* Project::CreateNewModel(bool ShowModel) lcModel* Model = new lcModel(Name, this, false); Model->CreatePieceInfo(this); Model->SetSaved(); - mModels.Add(Model); + mModels.emplace_back(Model); if (ShowModel) { - SetActiveModel(mModels.GetSize() - 1); + SetActiveModel(mModels.size() - 1); lcView* ActiveView = gMainWindow ? gMainWindow->GetActiveView() : nullptr; if (ActiveView) @@ -327,10 +327,10 @@ void Project::ShowModelListDialog() mModified = true; } - NewModels.Add(Model); + NewModels.emplace_back(Model); } - for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++) + for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++) { lcModel* Model = mModels[ModelIdx]; @@ -415,7 +415,7 @@ bool Project::Load(const QString& FileName, bool ShowErrors) if (std::find_if(Models.begin(), Models.end(), ModelCompare) == Models.end()) { - mModels.Add(Model); + mModels.emplace_back(Model); Models.emplace_back(std::make_pair(Pos, Model)); Model->CreatePieceInfo(this); } @@ -444,7 +444,7 @@ bool Project::Load(const QString& FileName, bool ShowErrors) if (Model->LoadBinary(&MemFile)) { - mModels.Add(Model); + mModels.emplace_back(Model); Model->CreatePieceInfo(this); Model->SetSaved(); } @@ -452,14 +452,14 @@ bool Project::Load(const QString& FileName, bool ShowErrors) delete Model; } - if (mModels.IsEmpty()) + if (mModels.empty()) { if (ShowErrors) QMessageBox::warning(parent, tr("Error"), tr("Error loading file '%1':\nFile format is not recognized.").arg(FileName)); return false; } - if (mModels.GetSize() == 1) + if (mModels.size() == 1) { lcModel* Model = mModels[0]; @@ -471,7 +471,7 @@ bool Project::Load(const QString& FileName, bool ShowErrors) } std::vector UpdatedModels; - UpdatedModels.reserve(mModels.GetSize()); + UpdatedModels.reserve(mModels.size()); for (lcModel* Model : mModels) { @@ -511,7 +511,7 @@ bool Project::Save(const QString& FileName) bool Project::Save(QTextStream& Stream) { - bool MPD = mModels.GetSize() > 1; + bool MPD = mModels.size() > 1; for (lcModel* Model : mModels) { @@ -538,7 +538,7 @@ void Project::Merge(Project* Other) { bool Duplicate = false; - for (int SearchIdx = 0; SearchIdx < mModels.GetSize(); SearchIdx++) + for (int SearchIdx = 0; SearchIdx < mModels.size(); SearchIdx++) { if (mModels[SearchIdx]->GetProperties().mFileName == FileName) { @@ -554,7 +554,7 @@ void Project::Merge(Project* Other) Model->SetFileName(FileName); } - mModels.Add(Model); + mModels.emplace_back(Model); } Other->mModels.RemoveAll(); @@ -578,7 +578,7 @@ bool Project::ImportLDD(const QString& FileName) if (Model->LoadLDD(QString::fromUtf8((const char*)XMLFile.mBuffer))) { - mModels.Add(Model); + mModels.emplace_back(Model); Model->SetSaved(); } else @@ -587,13 +587,13 @@ bool Project::ImportLDD(const QString& FileName) return false; } - for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++) + for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++) mModels[ModelIdx]->CreatePieceInfo(this); std::vector UpdatedModels; - UpdatedModels.reserve(mModels.GetSize()); + UpdatedModels.reserve(mModels.size()); - for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++) + for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++) mModels[ModelIdx]->UpdatePieceInfo(UpdatedModels); mModified = false; @@ -611,7 +611,7 @@ bool Project::ImportInventory(const QByteArray& Inventory, const QString& Name, if (Model->LoadInventory(Inventory)) { - mModels.Add(Model); + mModels.emplace_back(Model); Model->SetSaved(); } else @@ -622,13 +622,13 @@ bool Project::ImportInventory(const QByteArray& Inventory, const QString& Name, Model->SetDescription(Description); - for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++) + for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++) mModels[ModelIdx]->CreatePieceInfo(this); std::vector UpdatedModels; - UpdatedModels.reserve(mModels.GetSize()); + UpdatedModels.reserve(mModels.size()); - for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++) + for (int ModelIdx = 0; ModelIdx < mModels.size(); ModelIdx++) mModels[ModelIdx]->UpdatePieceInfo(UpdatedModels); mModified = false; @@ -640,7 +640,7 @@ std::vector Project::GetModelParts() { std::vector ModelParts; - if (mModels.IsEmpty()) + if (mModels.empty()) return ModelParts; for (lcModel* Model : mModels) @@ -698,7 +698,7 @@ bool Project::ExportCurrentStep(const QString& FileName) const lcStep CurrentStep = lcGetActiveModel()->GetCurrentStep(); - bool MPD = mModels.GetSize() > 1; + bool MPD = mModels.size() > 1; if (MPD) { @@ -1243,7 +1243,7 @@ void Project::ExportBrickLink() { lcPartsList PartsList; - if (!mModels.IsEmpty()) + if (!mModels.empty()) mModels[0]->GetPartsList(gDefaultColor, true, false, PartsList); if (PartsList.empty()) @@ -1536,7 +1536,7 @@ bool Project::ExportCSV(const QString& FileName) { lcPartsList PartsList; - if (!mModels.IsEmpty()) + if (!mModels.empty()) mModels[0]->GetPartsList(gDefaultColor, true, false, PartsList); if (PartsList.empty()) @@ -1594,10 +1594,10 @@ void Project::ExportHTML(const lcHTMLExportOptions& Options) lcArray Models; if (Options.CurrentOnly) - Models.Add(mActiveModel); + Models.emplace_back(mActiveModel); else if (Options.SubModels) { - Models.Add(mActiveModel); + Models.emplace_back(mActiveModel); mActiveModel->GetSubModels(Models); } else @@ -1626,7 +1626,7 @@ void Project::ExportHTML(const lcHTMLExportOptions& Options) lcStep LastStep = Model->GetLastStep(); QString PageTitle; - if (Models.GetSize() > 1) + if (Models.size() > 1) { BaseName += '-' + Model->GetProperties().mFileName; PageTitle = Model->GetProperties().mFileName; @@ -1756,7 +1756,7 @@ void Project::ExportHTML(const lcHTMLExportOptions& Options) Model->SaveStepImages(StepImageBaseName, true, false, Options.StepImagesWidth, Options.StepImagesHeight, 1, LastStep); } - if (Models.GetSize() > 1) + if (Models.size() > 1) { QString BaseName = ProjectTitle.left(ProjectTitle.length() - QFileInfo(ProjectTitle).suffix().length() - 1); QString FileName = QFileInfo(Dir, BaseName + QLatin1String("-index.html")).absoluteFilePath(); @@ -1772,7 +1772,7 @@ void Project::ExportHTML(const lcHTMLExportOptions& Options) Stream << QString::fromLatin1("\r\n\r\nInstructions for %1\r\n\r\n
\r\n
\r\n").arg(ProjectTitle); - for (int ModelIdx = 0; ModelIdx < Models.GetSize(); ModelIdx++) + for (int ModelIdx = 0; ModelIdx < Models.size(); ModelIdx++) { lcModel* Model = Models[ModelIdx]; BaseName = ProjectTitle.left(ProjectTitle.length() - QFileInfo(ProjectTitle).suffix().length() - 1) + '-' + Model->GetProperties().mFileName; @@ -2151,7 +2151,7 @@ bool Project::ExportPOVRay(const QString& FileName) lcLightType LightType = lcLightType::Area; float Power = 0.0f, FadeDistance = 0.0f, FadePower = 0.0f, SpotRadius = 0.0f, SpotFalloff = 0.0f, SpotTightness = 0.0f; - if (Lights.IsEmpty()) + if (Lights.empty()) { const lcVector3 LightTarget(0.0f, 0.0f, 0.0f), LightColor(1.0f, 1.0f, 1.0f); lcVector3 Location[4]; @@ -2660,7 +2660,7 @@ void Project::SaveImage() void Project::UpdatePieceInfo(PieceInfo* Info) const { - if (!mModels.IsEmpty()) + if (!mModels.empty()) { std::vector UpdatedModels; mModels[0]->UpdatePieceInfo(UpdatedModels); diff --git a/common/project.h b/common/project.h index 8b941e0c..a3b88423 100644 --- a/common/project.h +++ b/common/project.h @@ -58,7 +58,7 @@ public: lcModel* GetMainModel() const { - return !mModels.IsEmpty() ? mModels[0] : nullptr; + return !mModels.empty() ? mModels[0] : nullptr; } bool IsModified() const; diff --git a/qt/lc_qselectdialog.cpp b/qt/lc_qselectdialog.cpp index 7d080766..668498c8 100644 --- a/qt/lc_qselectdialog.cpp +++ b/qt/lc_qselectdialog.cpp @@ -26,7 +26,7 @@ lcQSelectDialog::~lcQSelectDialog() void lcQSelectDialog::accept() { - mObjects.RemoveAll(); + mObjects.clear(); QList Items; Items.append(ui->treeWidget->invisibleRootItem()); @@ -41,7 +41,7 @@ void lcQSelectDialog::accept() if (Item->checkState(0) == Qt::Checked) { lcObject* Object = (lcObject*)Item->data(0, IndexRole).value(); - mObjects.Add(Object); + mObjects.emplace_back(Object); } } else diff --git a/qt/lc_qselectdialog.h b/qt/lc_qselectdialog.h index 183ab4ed..63059b25 100644 --- a/qt/lc_qselectdialog.h +++ b/qt/lc_qselectdialog.h @@ -1,7 +1,6 @@ #pragma once #include -#include "lc_array.h" namespace Ui { class lcQSelectDialog; @@ -15,7 +14,7 @@ public: lcQSelectDialog(QWidget* Parent, lcModel* Model); ~lcQSelectDialog(); - lcArray mObjects; + std::vector mObjects; enum {