diff --git a/common/array.cpp b/common/array.cpp deleted file mode 100644 index 804e9b6f..00000000 --- a/common/array.cpp +++ /dev/null @@ -1,402 +0,0 @@ -// -// Simple array classes -// - -#include -#include - -template -PtrArray::PtrArray(int nSize) -{ - m_pData = NULL; - m_nLength = 0; - m_nAlloc = 0; - - if(nSize != 0) - Expand(nSize); -} - -template -PtrArray::~PtrArray() -{ - free(m_pData); -} - -template -void PtrArray::SetSize(int Size) -{ - if (Size > m_nLength) - Expand(Size - m_nLength); - - m_nLength = Size; -} - -template -void PtrArray::Expand(int nGrow) -{ - if ((m_nLength + nGrow) > m_nAlloc) - { - m_pData =(T**)realloc(m_pData,(m_nLength + nGrow) * sizeof(T*)); - memset(m_pData + m_nLength, 0, nGrow * sizeof(T*)); - m_nAlloc = m_nLength + nGrow; - } -} - -template -void PtrArray::RemoveAll() -{ - m_nLength = 0; -} - -template -T* PtrArray::RemoveIndex(int nIndex) -{ - T* ret = NULL; - - if(nIndex < m_nLength) - { - ret = m_pData[nIndex]; - - if(nIndex != m_nLength - 1) - memmove(m_pData + nIndex, m_pData + nIndex + 1, sizeof(T*) *(m_nLength - nIndex - 1)); - - m_nLength--; - m_pData[m_nLength] = NULL; - } - - return ret; -} - -template -T* PtrArray::RemovePointer(T* pObj) -{ - int i; - - for(i = 0; i < m_nLength; i++) - if(m_pData[i] == pObj) - return RemoveIndex(i); - - return NULL; -} - -template -void PtrArray::Add(T* pObj) -{ - Expand(1); - m_pData[m_nLength] = pObj; - m_nLength++; -} - -template -void PtrArray::AddSorted(T* pObj, LC_PTRARRAY_COMPARE_FUNC pFunc, void* pData) -{ - int i; - - for(i = 0; i < GetSize(); i++) - { - if(pFunc(pObj, m_pData[i], pData) < 0) - { - InsertAt(i, pObj); - return; - } - } - - Add(pObj); -} - -template -void PtrArray::SetAt(int Index, T* Ptr) -{ - m_pData[Index] = Ptr; -} - -template -void PtrArray::InsertAt(int nIndex, T* pObj) -{ - if(nIndex >= m_nLength) - Expand(nIndex - m_nLength + 1); - else - Expand(1); - - m_nLength++; - for(int i = m_nLength - 1; i > nIndex; i--) - m_pData[i] = m_pData[i-1]; - - m_pData[nIndex] = pObj; -} - -template -int PtrArray::FindIndex(T* Obj) const -{ - for (int i = 0; i < m_nLength; i++) - if (m_pData[i] == Obj) - return i; - - return -1; -} - -template -void PtrArray::Sort(LC_PTRARRAY_COMPARE_FUNC SortFunc, void* SortData) -{ - int Count = GetSize(); - - if (Count <= 1) - return; - - int i = 1; - bool Flipped; - - do - { - Flipped = false; - - for (int j = Count - 1; j >= i; --j) - { - T* a = m_pData[j]; - T* b = m_pData[j-1]; - - if (SortFunc(b, a, SortData) > 0) - { - m_pData[j - 1] = a; - m_pData[j] = b; - Flipped = true; - } - } - } while ((++i < Count) && Flipped); -} - -template -PtrArray& PtrArray::operator=(const PtrArray& Array) -{ - m_nLength = Array.m_nLength; - m_nAlloc = Array.m_nAlloc; - m_pData =(T**)realloc(m_pData, (m_nAlloc) * sizeof(T*)); - memcpy(m_pData, Array.m_pData, (m_nAlloc) * sizeof(T*)); -} - -template -PtrArray& PtrArray::operator+=(const PtrArray& Array) -{ - Expand(Array.m_nLength); - memcpy(m_pData + m_nLength, Array.m_pData, Array.m_nLength * sizeof(T*)); - m_nLength += Array.m_nLength; - return *this; -} - -// ============================================================================ - -template -ObjArray::ObjArray(int Size, int Grow) -{ - m_Data = NULL; - m_Length = 0; - m_Alloc = 0; - m_Grow = Grow; - - if (Size != 0) - Expand(Size); -} - -template -ObjArray::~ObjArray () -{ - delete[] m_Data; -} - -template -void ObjArray::Expand(int Grow) -{ - if ((m_Length + Grow) > m_Alloc) - { - int NewSize = ((m_Length + Grow + m_Grow - 1) / m_Grow) * m_Grow; - - T* NewData = new T[NewSize]; - - for (int i = 0; i < m_Length; i++) - NewData[i] = m_Data[i]; - - delete[] m_Data; - m_Data = NewData; - m_Alloc = NewSize; - } -} - -template -void ObjArray::RemoveAll() -{ - m_Length = 0; -} - -template -void ObjArray::RemoveIndex(int Index) -{ - m_Length--; - - for (int i = Index; i < m_Length; i++) - m_Data[i] = m_Data[i+1]; -} - -template -void ObjArray::SetSize(int NewSize) -{ - if (NewSize > m_Alloc) - Expand(NewSize - m_Alloc); - - m_Length = NewSize; -} - -template -void ObjArray::Add(const T& Obj) -{ - Expand(1); - m_Data[m_Length++] = Obj; -} - -template -T& ObjArray::Add() -{ - Expand(1); - return m_Data[m_Length++]; -} - -template -void ObjArray::AddSorted (const T& Obj, LC_OBJARRAY_COMPARE_FUNC Func, void* SortData) -{ - int i; - - for (i = 0; i < GetSize(); i++) - { - if (Func(Obj, m_Data[i], SortData) < 0) - { - InsertAt(i, Obj); - return; - } - } - - Add(Obj); -} - -template -void ObjArray::InsertAt(int Index, const T& Obj) -{ - if (Index >= m_Length) - Expand(Index - m_Length + 1); - else - Expand(1); - - m_Length++; - for (int i = m_Length - 1; i > Index; i--) - m_Data[i] = m_Data[i-1]; - - m_Data[Index] = Obj; -} - -template -void ObjArray::Sort(LC_OBJARRAY_COMPARE_FUNC SortFunc, void* SortData) -{ - int Count = GetSize(); - - if (Count <= 1) - return; - - int i = 1; - bool Flipped; - - do - { - Flipped = false; - - for (int j = Count - 1; j >= i; --j) - { - T& a = m_Data[j]; - T& b = m_Data[j-1]; - - if (SortFunc(b, a, SortData) > 0) - { - T Tmp = b; - m_Data[j - 1] = a; - m_Data[j] = Tmp; - Flipped = true; - } - } - } while ((++i < Count) && Flipped); -} - - - - - - -/* -// ============================================================================ -// ObjectArray class - -ObjectArray::ObjectArray (unsigned long nSize) -{ - m_pData = NULL; - m_nLength = 0; - m_nAlloc = 0; - - if (nSize != 0) - Expand (nSize); -} - -ObjectArray::~ObjectArray () -{ - free (m_pData); -} - -void ObjectArray::Expand (unsigned long nGrow) -{ - if ((m_nLength + nGrow) > m_nAlloc) - { - m_pData = (Object**)realloc (m_pData, (m_nLength + nGrow) * sizeof (Object*)); - memset (m_pData + m_nLength, 0, nGrow * sizeof (Object*)); - m_nAlloc = m_nLength + nGrow; - } -} - -void ObjectArray::SetSize (unsigned long nSize) -{ - if (nSize > m_nLength) - Expand (nSize - m_nLength); - - m_nLength = nSize; -} - -Object* ObjectArray::RemoveIndex (unsigned long nIndex) -{ - Object* ret = NULL; - - if (nIndex < m_nLength) - { - ret = m_pData[nIndex]; - - if (nIndex != m_nLength - 1) - memmove (m_pData + nIndex, m_pData + nIndex + 1, - sizeof (Object*) * (m_nLength - nIndex - 1)); - - m_nLength--; - m_pData[m_nLength] = NULL; - } - - return ret; -} - -Object* ObjectArray::RemovePointer (Object* pObj) -{ - unsigned long i; - - for (i = 0; i < m_nLength; i++) - if (m_pData[i] == pObj) - return RemoveIndex (i); - - return NULL; -} - -void ObjectArray::Add (Object* pObj) -{ - Expand (1); - m_pData[m_nLength++] = pObj; -} -*/ diff --git a/common/array.h b/common/array.h deleted file mode 100644 index e9008d06..00000000 --- a/common/array.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef _ARRAY_H_ -#define _ARRAY_H_ - -template -class PtrArray -{ -public: - PtrArray(int nSize = 0); - ~PtrArray(); - - typedef int (*LC_PTRARRAY_COMPARE_FUNC)(const T* a, const T* b, void* data); - - int GetSize() const - { return m_nLength; } - void SetSize(int Size); - void Expand(int nGrow); - - T* RemoveIndex(int nIndex); - T* RemovePointer(T* pObj); - void RemoveAll(); - void Add(T* pObj); - void AddSorted(T* pObj, LC_PTRARRAY_COMPARE_FUNC pFunc, void* pData); - void SetAt(int Index, T* Ptr); - void InsertAt(int nIndex, T* pObj); - int FindIndex(T* Obj) const; - void Sort(LC_PTRARRAY_COMPARE_FUNC SortFunc, void* SortData); - - PtrArray& operator=(const PtrArray& Array); - PtrArray& operator+=(const PtrArray& Array); - T* operator [](int nIndex) const - { return m_pData[nIndex]; } - -protected: - T** m_pData; - int m_nLength; - int m_nAlloc; -}; - -template -class ObjArray -{ -public: - ObjArray(int Size = 0, int Grow = 16); - ~ObjArray(); - - typedef int (*LC_OBJARRAY_COMPARE_FUNC)(const T& A, const T& B, void* SortData); - - int GetSize() const - { return m_Length; } - - void RemoveIndex(int Index); - void RemoveAll(); - void SetSize(int NewSize); - void Expand(int Grow); - void Add(const T& Obj); - T& Add(); - void AddSorted(const T& Obj, LC_OBJARRAY_COMPARE_FUNC Func, void* SortData); - void InsertAt(int Index, const T& Obj); - void Sort(LC_OBJARRAY_COMPARE_FUNC SortFunc, void* SortData); - - ObjArray& operator=(const ObjArray& Array) - { - m_Length = Array.m_Length; - m_Alloc = Array.m_Alloc; - m_Grow = Array.m_Grow; - - delete[] m_Data; - m_Data = new T[m_Alloc]; - - for (int i = 0; i < m_Length; i++) - m_Data[i] = Array.m_Data[i]; - - return *this; - } - - T& operator [](int Index) const - { return m_Data[Index]; } - -protected: - T* m_Data; - int m_Length; - int m_Alloc; - int m_Grow; -}; - -#include "array.cpp" - -#endif // _ARRAY_H_ diff --git a/common/basewnd.h b/common/basewnd.h index 9980e754..c4200ec0 100644 --- a/common/basewnd.h +++ b/common/basewnd.h @@ -3,7 +3,7 @@ #include "defines.h" #include "lc_math.h" -#include "array.h" +#include "lc_array.h" #include "project.h" #include "lc_category.h" #include "image.h" @@ -117,7 +117,7 @@ struct lcPropertiesDialogOptions bool DrawFloor; bool SetDefault; - ObjArray PartsUsed; + lcArray PartsUsed; }; struct lcArrayDialogOptions @@ -129,13 +129,13 @@ struct lcArrayDialogOptions struct lcEditGroupsDialogOptions { - PtrArray PieceParents; - PtrArray GroupParents; + lcArray PieceParents; + lcArray GroupParents; }; struct lcSelectDialogOptions { - ObjArray Selection; + lcArray Selection; }; struct lcPreferencesDialogOptions @@ -152,7 +152,7 @@ struct lcPreferencesDialogOptions int AASamples; int GridSize; - ObjArray Categories; + lcArray Categories; bool CategoriesModified; bool CategoriesDefault; diff --git a/common/camera.cpp b/common/camera.cpp index eee2871d..e2d2ad52 100644 --- a/common/camera.cpp +++ b/common/camera.cpp @@ -164,7 +164,7 @@ void Camera::Initialize() m_pTarget = new CameraTarget(this); } -void Camera::CreateName(const PtrArray& Cameras) +void Camera::CreateName(const lcArray& Cameras) { int i, max = 0; const char* Prefix = "Camera "; diff --git a/common/camera.h b/common/camera.h index e4cb5ecb..473bc1da 100644 --- a/common/camera.h +++ b/common/camera.h @@ -3,7 +3,7 @@ #include "object.h" #include "lc_math.h" -#include "array.h" +#include "lc_array.h" #define LC_CAMERA_HIDDEN 0x01 #define LC_CAMERA_SELECTED 0x02 @@ -80,7 +80,7 @@ public: return m_strName; } - void CreateName(const PtrArray& Cameras); + void CreateName(const lcArray& Cameras); CameraTarget* GetTarget() const { diff --git a/common/curve.h b/common/curve.h index 9777c2e4..1761a704 100644 --- a/common/curve.h +++ b/common/curve.h @@ -3,7 +3,6 @@ #if 0 #include "object.h" #include "opengl.h" -#include "array.h" class Curve; class CurvePoint; @@ -121,7 +120,7 @@ class Curve : public Object GLuint m_nDisplayList; - PtrArray m_Points; + lcArray m_Points; }; #endif #endif // _CURVE_H_ diff --git a/common/lc_application.h b/common/lc_application.h index d171635c..0f2dfd25 100644 --- a/common/lc_application.h +++ b/common/lc_application.h @@ -1,7 +1,7 @@ #ifndef _LC_APPLICATION_H_ #define _LC_APPLICATION_H_ -#include "array.h" +#include "lc_array.h" #include "str.h" class Project; @@ -18,7 +18,7 @@ public: bool LoadPiecesLibrary(const char* LibPath, const char* LibraryInstallPath, const char* LibraryCachePath); - void GetFileList(const char* Path, ObjArray& FileList); + void GetFileList(const char* Path, lcArray& FileList); void OpenURL(const char* URL); void SetClipboard(lcFile* Clipboard); void ExportClipboard(lcMemFile* Clipboard); diff --git a/common/lc_array.h b/common/lc_array.h new file mode 100644 index 00000000..adbca722 --- /dev/null +++ b/common/lc_array.h @@ -0,0 +1,195 @@ +#ifndef _LC_ARRAY_H_ +#define _LC_ARRAY_H_ + +template +class lcArray +{ +public: + typedef int (*lcArrayCompareFunc)(const T& a, const T& b); + + lcArray(int Size = 0, int Grow = 16) + { + mData = NULL; + mLength = 0; + mAlloc = 0; + mGrow = Grow; + + if (Size != 0) + AllocGrow(Size); + } + + ~lcArray() + { + delete[] mData; + } + + lcArray& operator=(const lcArray& Array) + { + mLength = Array.mLength; + mAlloc = Array.mAlloc; + mGrow = Array.mGrow; + + delete[] mData; + mData = new T[mAlloc]; + + for (int i = 0; i < mLength; i++) + mData[i] = Array.mData[i]; + + return *this; + } + + lcArray& operator+=(const lcArray& Array) + { + AllocGrow(Array.mLength); + + for (int i = mLength; i < mLength + Array.mLength; i++) + mData[i] = Array.mData[i]; + + mLength += Array.mLength; + return *this; + } + + T& operator[](int Index) const + { + return mData[Index]; + } + + int GetSize() const + { + return mLength; + } + + void SetSize(int NewSize) + { + if (NewSize > mAlloc) + AllocGrow(NewSize - mAlloc); + + mLength = NewSize; + } + + void AllocGrow(int Grow) + { + if ((mLength + Grow) > mAlloc) + { + int NewSize = ((mLength + Grow + mGrow - 1) / mGrow) * mGrow; + T* NewData = new T[NewSize]; + + for (int i = 0; i < mLength; i++) + NewData[i] = mData[i]; + + delete[] mData; + mData = NewData; + mAlloc = NewSize; + } + } + + void Add(const T& NewItem) + { + AllocGrow(1); + mData[mLength++] = NewItem; + } + + T& Add() + { + AllocGrow(1); + return mData[mLength++]; + } + + void AddSorted(const T& Obj, lcArrayCompareFunc CompareFunc) + { + for (int i = 0; i < mLength; i++) + { + if (CompareFunc(Obj, mData[i]) < 0) + { + InsertAt(i, Obj); + return; + } + } + + Add(Obj); + } + + void InsertAt(int Index, const T& NewItem) + { + if (Index >= mLength) + AllocGrow(Index - mLength + 1); + else + AllocGrow(1); + + mLength++; + for (int i = mLength - 1; i > Index; i--) + mData[i] = mData[i - 1]; + + mData[Index] = NewItem; + } + + void RemoveIndex(int Index) + { + mLength--; + + for (int i = Index; i < mLength; i++) + mData[i] = mData[i + 1]; + } + + void Remove(const T& Item) + { + for (int i = 0; i < mLength; i++) + { + if (mData[i] == Item) + { + RemoveIndex(i); + return; + } + } + } + + void RemoveAll() + { + mLength = 0; + } + + int FindIndex(const T& Item) const + { + for (int i = 0; i < mLength; i++) + if (mData[i] == Item) + return i; + + return -1; + } + + void Sort(lcArrayCompareFunc CompareFunc) + { + if (mLength <= 1) + return; + + int i = 1; + bool Flipped; + + do + { + Flipped = false; + + for (int j = mLength - 1; j >= i; --j) + { + T& a = mData[j]; + T& b = mData[j - 1]; + + if (CompareFunc(b, a) > 0) + { + T Tmp = b; + mData[j - 1] = a; + mData[j] = Tmp; + Flipped = true; + } + } + } while ((++i < mLength) && Flipped); + } + +protected: + T* mData; + int mLength; + int mAlloc; + int mGrow; +}; + +#endif // _LC_ARRAY_H_ diff --git a/common/lc_category.cpp b/common/lc_category.cpp index 6e847f38..759e0314 100644 --- a/common/lc_category.cpp +++ b/common/lc_category.cpp @@ -3,7 +3,7 @@ #include "lc_file.h" #include "lc_profile.h" -ObjArray gCategories; +lcArray gCategories; void lcResetDefaultCategories() { @@ -31,7 +31,7 @@ void lcSaveDefaultCategories() lcSetProfileBuffer(LC_PROFILE_CATEGORIES, File); } -void lcResetCategories(ObjArray& Categories, bool BuiltInLibrary) +void lcResetCategories(lcArray& Categories, bool BuiltInLibrary) { const char DefaultCategories[] = { @@ -86,7 +86,7 @@ void lcResetCategories(ObjArray& Categories, bool BuiltInLibr lcLoadCategories(File, Categories); } -bool lcLoadCategories(const char* FileName, ObjArray& Categories) +bool lcLoadCategories(const char* FileName, lcArray& Categories) { lcDiskFile File; @@ -96,7 +96,7 @@ bool lcLoadCategories(const char* FileName, ObjArray& Categor return lcLoadCategories(File, Categories); } -bool lcLoadCategories(lcFile& File, ObjArray& Categories) +bool lcLoadCategories(lcFile& File, lcArray& Categories) { Categories.RemoveAll(); @@ -125,7 +125,7 @@ bool lcLoadCategories(lcFile& File, ObjArray& Categories) return true; } -bool lcSaveCategories(const char* FileName, const ObjArray& Categories) +bool lcSaveCategories(const char* FileName, const lcArray& Categories) { lcDiskFile File; @@ -135,7 +135,7 @@ bool lcSaveCategories(const char* FileName, const ObjArray& C return lcSaveCategories(File, Categories); } -bool lcSaveCategories(lcFile& File, const ObjArray& Categories) +bool lcSaveCategories(lcFile& File, const lcArray& Categories) { char Line[1024]; diff --git a/common/lc_category.h b/common/lc_category.h index b77e1d1f..bc80daa9 100644 --- a/common/lc_category.h +++ b/common/lc_category.h @@ -2,7 +2,7 @@ #define _LC_CATEGORY_H_ #include "str.h" -#include "array.h" +#include "lc_array.h" struct lcLibraryCategory { @@ -10,16 +10,16 @@ struct lcLibraryCategory String Keywords; }; -extern ObjArray gCategories; +extern lcArray gCategories; void lcResetDefaultCategories(); void lcLoadDefaultCategories(bool BuiltInLibrary = false); void lcSaveDefaultCategories(); -void lcResetCategories(ObjArray& Categories, bool BuiltInLibrary = false); -bool lcLoadCategories(const char* FileName, ObjArray& Categories); -bool lcLoadCategories(lcFile& File, ObjArray& Categories); -bool lcSaveCategories(const char* FileName, const ObjArray& Categories); -bool lcSaveCategories(lcFile& File, const ObjArray& Categories); +void lcResetCategories(lcArray& Categories, bool BuiltInLibrary = false); +bool lcLoadCategories(const char* FileName, lcArray& Categories); +bool lcLoadCategories(lcFile& File, lcArray& Categories); +bool lcSaveCategories(const char* FileName, const lcArray& Categories); +bool lcSaveCategories(lcFile& File, const lcArray& Categories); #endif // _LC_CATEGORY_H_ diff --git a/common/lc_colors.cpp b/common/lc_colors.cpp index d86ea7e0..73478549 100644 --- a/common/lc_colors.cpp +++ b/common/lc_colors.cpp @@ -3,7 +3,7 @@ #include "lc_file.h" #include -ObjArray gColorList; +lcArray gColorList; lcColorGroup gColorGroups[LC_NUM_COLORGROUPS]; int gNumUserColors; int gEdgeColor; @@ -345,7 +345,7 @@ int lcGetBrickLinkColor(int ColorIndex) bool lcLoadColorFile(lcFile& File) { char Line[1024], Token[1024]; - ObjArray& Colors = gColorList; + lcArray& Colors = gColorList; lcColor Color, MainColor, EdgeColor; Colors.RemoveAll(); diff --git a/common/lc_colors.h b/common/lc_colors.h index bd4088f1..ea0309d7 100644 --- a/common/lc_colors.h +++ b/common/lc_colors.h @@ -2,7 +2,7 @@ #define _LC_COLORS_H_ #include "opengl.h" -#include "array.h" +#include "lc_array.h" #define LC_MAX_COLOR_NAME 64 #define LC_COLOR_DIRECT 0x80000000 @@ -27,11 +27,11 @@ enum struct lcColorGroup { - ObjArray Colors; + lcArray Colors; char Name[LC_MAX_COLOR_NAME]; }; -extern ObjArray gColorList; +extern lcArray gColorList; extern lcColorGroup gColorGroups[LC_NUM_COLORGROUPS]; extern int gNumUserColors; extern int gEdgeColor; diff --git a/common/lc_library.cpp b/common/lc_library.cpp index 030662ea..7c8e7078 100644 --- a/common/lc_library.cpp +++ b/common/lc_library.cpp @@ -301,7 +301,7 @@ bool lcPiecesLibrary::OpenDirectory(const char* Path) Unload(); char FileName[LC_MAXPATH]; - ObjArray FileList; + lcArray FileList; strcpy(FileName, Path); strcat(FileName, "parts.lst"); @@ -373,7 +373,7 @@ bool lcPiecesLibrary::OpenDirectory(const char* Path) g_App->GetFileList(FileName, FileList); - mPieces.Expand(FileList.GetSize()); + mPieces.AllocGrow(FileList.GetSize()); for (int FileIdx = 0; FileIdx < FileList.GetSize(); FileIdx++) { @@ -488,7 +488,7 @@ bool lcPiecesLibrary::OpenDirectory(const char* Path) g_App->GetFileList(FileName, FileList); - mTextures.Expand(FileList.GetSize()); + mTextures.AllocGrow(FileList.GetSize()); for (int FileIdx = 0; FileIdx < FileList.GetSize(); FileIdx++) { @@ -710,7 +710,7 @@ void lcPiecesLibrary::SaveCacheFile() mSaveCache = false; } -int LibraryMeshSectionCompare(const lcLibraryMeshSection* a, const lcLibraryMeshSection* b, void* Data) +int LibraryMeshSectionCompare(lcLibraryMeshSection* const& a, lcLibraryMeshSection* const& b) { if (a->mPrimitiveType != b->mPrimitiveType) { @@ -746,7 +746,7 @@ int LibraryMeshSectionCompare(const lcLibraryMeshSection* a, const lcLibraryMesh bool lcPiecesLibrary::LoadPiece(PieceInfo* Info) { lcLibraryMeshData MeshData; - ObjArray TextureStack; + lcArray TextureStack; if (mZipFile) { @@ -799,7 +799,7 @@ bool lcPiecesLibrary::LoadPiece(PieceInfo* Info) NumIndices += Section->mIndices.GetSize(); } - MeshData.mSections.Sort(LibraryMeshSectionCompare, NULL); + MeshData.mSections.Sort(LibraryMeshSectionCompare); Mesh->Create(MeshData.mSections.GetSize(), MeshData.mVertices.GetSize(), MeshData.mTexturedVertices.GetSize(), NumIndices); @@ -955,7 +955,7 @@ int lcPiecesLibrary::FindPrimitiveIndex(const char* Name) bool lcPiecesLibrary::LoadPrimitive(int PrimitiveIndex) { lcLibraryPrimitive* Primitive = mPrimitives[PrimitiveIndex]; - ObjArray TextureStack; + lcArray TextureStack; if (mZipFile) { @@ -993,7 +993,7 @@ bool lcPiecesLibrary::LoadPrimitive(int PrimitiveIndex) return true; } -bool lcPiecesLibrary::ReadMeshData(lcFile& File, const lcMatrix44& CurrentTransform, lcuint32 CurrentColorCode, ObjArray& TextureStack, lcLibraryMeshData& MeshData) +bool lcPiecesLibrary::ReadMeshData(lcFile& File, const lcMatrix44& CurrentTransform, lcuint32 CurrentColorCode, lcArray& TextureStack, lcLibraryMeshData& MeshData) { char Buffer[1024]; char* Line; @@ -1540,11 +1540,11 @@ void lcLibraryMeshData::AddTexturedLine(int LineType, lcuint32 ColorCode, const void lcLibraryMeshData::AddMeshData(const lcLibraryMeshData& Data, const lcMatrix44& Transform, lcuint32 CurrentColorCode, lcLibraryTextureMap* TextureMap) { int VertexCount = Data.mVertices.GetSize(); - ObjArray IndexRemap(VertexCount); + lcArray IndexRemap(VertexCount); if (!TextureMap) { - mVertices.Expand(VertexCount); + mVertices.AllocGrow(VertexCount); for (int SrcVertexIdx = 0; SrcVertexIdx < VertexCount; SrcVertexIdx++) { @@ -1575,7 +1575,7 @@ void lcLibraryMeshData::AddMeshData(const lcLibraryMeshData& Data, const lcMatri } else { - mTexturedVertices.Expand(VertexCount); + mTexturedVertices.AllocGrow(VertexCount); for (int SrcVertexIdx = 0; SrcVertexIdx < VertexCount; SrcVertexIdx++) { @@ -1611,11 +1611,11 @@ void lcLibraryMeshData::AddMeshData(const lcLibraryMeshData& Data, const lcMatri } int TexturedVertexCount = Data.mTexturedVertices.GetSize(); - ObjArray TexturedIndexRemap(TexturedVertexCount); + lcArray TexturedIndexRemap(TexturedVertexCount); if (TexturedVertexCount) { - mTexturedVertices.Expand(TexturedVertexCount); + mTexturedVertices.AllocGrow(TexturedVertexCount); for (int SrcVertexIdx = 0; SrcVertexIdx < TexturedVertexCount; SrcVertexIdx++) { @@ -1680,7 +1680,7 @@ void lcLibraryMeshData::AddMeshData(const lcLibraryMeshData& Data, const lcMatri mSections.Add(DstSection); } - DstSection->mIndices.Expand(SrcSection->mIndices.GetSize()); + DstSection->mIndices.AllocGrow(SrcSection->mIndices.GetSize()); if (!SrcSection->mTexture) { @@ -1703,7 +1703,7 @@ void lcLibraryMeshData::AddMeshDataNoDuplicateCheck(const lcLibraryMeshData& Dat { BaseIndex = mVertices.GetSize(); - mVertices.Expand(Data.mVertices.GetSize()); + mVertices.AllocGrow(Data.mVertices.GetSize()); for (int SrcVertexIdx = 0; SrcVertexIdx < Data.mVertices.GetSize(); SrcVertexIdx++) { @@ -1715,7 +1715,7 @@ void lcLibraryMeshData::AddMeshDataNoDuplicateCheck(const lcLibraryMeshData& Dat { BaseIndex = mTexturedVertices.GetSize(); - mTexturedVertices.Expand(Data.mVertices.GetSize()); + mTexturedVertices.AllocGrow(Data.mVertices.GetSize()); for (int SrcVertexIdx = 0; SrcVertexIdx < Data.mVertices.GetSize(); SrcVertexIdx++) { @@ -1736,7 +1736,7 @@ void lcLibraryMeshData::AddMeshDataNoDuplicateCheck(const lcLibraryMeshData& Dat if (TexturedVertexCount) { - mTexturedVertices.Expand(TexturedVertexCount); + mTexturedVertices.AllocGrow(TexturedVertexCount); for (int SrcVertexIdx = 0; SrcVertexIdx < TexturedVertexCount; SrcVertexIdx++) { @@ -1779,7 +1779,7 @@ void lcLibraryMeshData::AddMeshDataNoDuplicateCheck(const lcLibraryMeshData& Dat mSections.Add(DstSection); } - DstSection->mIndices.Expand(SrcSection->mIndices.GetSize()); + DstSection->mIndices.AllocGrow(SrcSection->mIndices.GetSize()); if (!SrcSection->mTexture) { @@ -1809,7 +1809,7 @@ bool lcPiecesLibrary::PieceInCategory(PieceInfo* Info, const String& CategoryKey return PieceName.Match(Keywords); } -void lcPiecesLibrary::GetCategoryEntries(int CategoryIndex, bool GroupPieces, PtrArray& SinglePieces, PtrArray& GroupedPieces) +void lcPiecesLibrary::GetCategoryEntries(int CategoryIndex, bool GroupPieces, lcArray& SinglePieces, lcArray& GroupedPieces) { if (gCategories[CategoryIndex].Name == "Search Results") GroupPieces = false; @@ -1817,7 +1817,7 @@ void lcPiecesLibrary::GetCategoryEntries(int CategoryIndex, bool GroupPieces, Pt SearchPieces(gCategories[CategoryIndex].Keywords, GroupPieces, SinglePieces, GroupedPieces); } -void lcPiecesLibrary::SearchPieces(const String& CategoryKeywords, bool GroupPieces, PtrArray& SinglePieces, PtrArray& GroupedPieces) +void lcPiecesLibrary::SearchPieces(const String& CategoryKeywords, bool GroupPieces, lcArray& SinglePieces, lcArray& GroupedPieces) { SinglePieces.RemoveAll(); GroupedPieces.RemoveAll(); @@ -1877,7 +1877,7 @@ void lcPiecesLibrary::SearchPieces(const String& CategoryKeywords, bool GroupPie } } -void lcPiecesLibrary::GetPatternedPieces(PieceInfo* Parent, PtrArray& Pieces) const +void lcPiecesLibrary::GetPatternedPieces(PieceInfo* Parent, lcArray& Pieces) const { char Name[LC_PIECE_NAME_LEN]; strcpy(Name, Parent->m_strName); diff --git a/common/lc_library.h b/common/lc_library.h index 4add192a..4b6ac546 100644 --- a/common/lc_library.h +++ b/common/lc_library.h @@ -3,7 +3,7 @@ #include "lc_mesh.h" #include "lc_math.h" -#include "array.h" +#include "lc_array.h" #include "str.h" class PieceInfo; @@ -36,7 +36,7 @@ public: LC_MESH_PRIMITIVE_TYPE mPrimitiveType; lcuint32 mColor; lcTexture* mTexture; - ObjArray mIndices; + lcArray mIndices; }; struct lcLibraryTextureMap @@ -68,9 +68,9 @@ public: void TestQuad(lcVector3* Vertices); void ResequenceQuad(lcVector3* Vertices, int a, int b, int c, int d); - PtrArray mSections; - ObjArray mVertices; - ObjArray mTexturedVertices; + lcArray mSections; + lcArray mVertices; + lcArray mTexturedVertices; }; class lcLibraryPrimitive @@ -117,15 +117,15 @@ public: void CloseCache(); bool PieceInCategory(PieceInfo* Info, const String& CategoryKeywords) const; - void SearchPieces(const String& CategoryKeywords, bool GroupPieces, PtrArray& SinglePieces, PtrArray& GroupedPieces); - void GetCategoryEntries(int CategoryIndex, bool GroupPieces, PtrArray& SinglePieces, PtrArray& GroupedPieces); - void GetPatternedPieces(PieceInfo* Parent, PtrArray& Pieces) const; + void SearchPieces(const String& CategoryKeywords, bool GroupPieces, lcArray& SinglePieces, lcArray& GroupedPieces); + void GetCategoryEntries(int CategoryIndex, bool GroupPieces, lcArray& SinglePieces, lcArray& GroupedPieces); + void GetPatternedPieces(PieceInfo* Parent, lcArray& Pieces) const; - PtrArray mPieces; - PtrArray mPrimitives; + lcArray mPieces; + lcArray mPrimitives; int mNumOfficialPieces; - PtrArray mTextures; + lcArray mTextures; char mLibraryPath[LC_MAXPATH]; @@ -139,7 +139,7 @@ protected: int FindPrimitiveIndex(const char* Name); bool LoadPrimitive(int PrimitiveIndex); - bool ReadMeshData(lcFile& File, const lcMatrix44& CurrentTransform, lcuint32 CurrentColorCode, ObjArray& TextureStack, lcLibraryMeshData& MeshData); + bool ReadMeshData(lcFile& File, const lcMatrix44& CurrentTransform, lcuint32 CurrentColorCode, lcArray& TextureStack, lcLibraryMeshData& MeshData); char mCacheFileName[LC_MAXPATH]; lcuint64 mCacheFileModifiedTime; diff --git a/common/lc_zipfile.cpp b/common/lc_zipfile.cpp index f57092f3..b494fd55 100644 --- a/common/lc_zipfile.cpp +++ b/common/lc_zipfile.cpp @@ -362,7 +362,7 @@ bool lcZipFile::ReadCentralDir() lcuint64 PosInCentralDir = mCentralDirOffset; mFile->Seek((long)(PosInCentralDir + mBytesBeforeZipFile), SEEK_SET); - mFiles.Expand((int)mNumEntries); + mFiles.AllocGrow((int)mNumEntries); for (lcuint64 FileNum = 0; FileNum < mNumEntries; FileNum++) { diff --git a/common/lc_zipfile.h b/common/lc_zipfile.h index 61e569a0..524a533b 100644 --- a/common/lc_zipfile.h +++ b/common/lc_zipfile.h @@ -1,7 +1,7 @@ #ifndef _LC_ZIPFILE_H_ #define _LC_ZIPFILE_H_ -#include "array.h" +#include "lc_array.h" #ifdef DeleteFile #undef DeleteFile @@ -61,7 +61,7 @@ public: bool AddFile(const char* FileName, lcMemFile& File); bool DeleteFile(const char* FileName); - ObjArray mFiles; + lcArray mFiles; protected: bool Open(); diff --git a/common/mainwnd.h b/common/mainwnd.h index 857482b5..06e0d32b 100644 --- a/common/mainwnd.h +++ b/common/mainwnd.h @@ -2,7 +2,7 @@ #define _MAINWND_H_ #include "basewnd.h" -#include "array.h" +#include "lc_array.h" class Object; class Camera; @@ -41,7 +41,7 @@ class lcMainWindow : public lcBaseWindow void UpdateUndoRedo(const char* UndoText, const char* RedoText); void UpdateTransformType(int NewType); void UpdateCurrentCamera(int CameraIndex); - void UpdateCameraMenu(const PtrArray& Cameras, Camera* CurrentCamera); + void UpdateCameraMenu(const lcArray& Cameras, Camera* CurrentCamera); void UpdateCategories(); void UpdateTitle(const char* Title, bool Modified); void UpdateModified(bool Modified); diff --git a/common/minifig.cpp b/common/minifig.cpp index 4a454a7e..e81e7d15 100644 --- a/common/minifig.cpp +++ b/common/minifig.cpp @@ -934,7 +934,7 @@ void MinifigWizard::ParseSettings(lcFile& Settings) for (int SectionIndex = 0; SectionIndex < LC_MFW_NUMITEMS; SectionIndex++) { - ObjArray& InfoArray = mSettings[SectionIndex]; + lcArray& InfoArray = mSettings[SectionIndex]; InfoArray.RemoveAll(); Settings.Seek(0, SEEK_SET); @@ -1395,7 +1395,7 @@ void MinifigWizard::Calculate() int MinifigWizard::GetSelectionIndex(int Type) const { - const ObjArray& InfoArray = mSettings[Type]; + const lcArray& InfoArray = mSettings[Type]; for (int Index = 0; Index < InfoArray.GetSize(); Index++) if (InfoArray[Index].Info == mMinifig->Parts[Type]) diff --git a/common/minifig.h b/common/minifig.h index bb93c83d..4f9483c5 100644 --- a/common/minifig.h +++ b/common/minifig.h @@ -3,7 +3,7 @@ #include "lc_glwidget.h" #include "lc_math.h" -#include "array.h" +#include "lc_array.h" class PieceInfo; @@ -67,7 +67,7 @@ public: void ParseSettings(lcFile& Settings); - ObjArray mSettings[LC_MFW_NUMITEMS]; + lcArray mSettings[LC_MFW_NUMITEMS]; lcMinifig* mMinifig; diff --git a/common/project.cpp b/common/project.cpp index 8031fcde..05abfacc 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -863,7 +863,7 @@ void Project::FileSave(lcFile* file, bool bUndo) } } -void Project::FileReadMPD(lcFile& MPD, PtrArray& FileArray) const +void Project::FileReadMPD(lcFile& MPD, lcArray& FileArray) const { LC_FILEENTRY* CurFile = NULL; char Buf[1024]; @@ -911,7 +911,7 @@ void Project::FileReadMPD(lcFile& MPD, PtrArray& FileArray) const } } -void Project::FileReadLDraw(lcFile* file, const lcMatrix44& CurrentTransform, int* nOk, int DefColor, int* nStep, PtrArray& FileArray) +void Project::FileReadLDraw(lcFile* file, const lcMatrix44& CurrentTransform, int* nOk, int DefColor, int* nStep, lcArray& FileArray) { char buf[1024]; @@ -1280,7 +1280,7 @@ bool Project::OnOpenDocument (const char* lpszPathName) if (file.GetLength() != 0) { - PtrArray FileArray; + lcArray FileArray; // Unpack the MPD file. if (mpdfile) @@ -1405,7 +1405,7 @@ void Project::CheckPoint (const char* text) gMainWindow->UpdateUndoRedo(m_pUndoList->pNext ? m_pUndoList->strText : NULL, NULL); } -void Project::AddView (View* pView) +void Project::AddView(View* pView) { m_ViewList.Add (pView); @@ -1416,12 +1416,12 @@ void Project::AddView (View* pView) m_ActiveView = pView; } -void Project::RemoveView (View* pView) +void Project::RemoveView(View* pView) { if (pView == m_ActiveView) m_ActiveView = NULL; - m_ViewList.RemovePointer(pView); + m_ViewList.Remove(pView); } void Project::UpdateAllViews() @@ -1596,7 +1596,7 @@ struct lcTranslucentRenderSection Piece* piece; }; -int lcTranslucentRenderCompare(const lcTranslucentRenderSection& a, const lcTranslucentRenderSection& b, void*) +int lcTranslucentRenderCompare(const lcTranslucentRenderSection& a, const lcTranslucentRenderSection& b) { if (a.Distance > b.Distance) return 1; @@ -1604,7 +1604,7 @@ int lcTranslucentRenderCompare(const lcTranslucentRenderSection& a, const lcTran return -1; } -int lcOpaqueRenderCompare(const Piece* a, const Piece* b, void*) +int lcOpaqueRenderCompare(Piece* const& a, Piece* const& b) { if (a->mPieceInfo > b->mPieceInfo) return 1; @@ -1665,8 +1665,8 @@ void Project::RenderScenePieces(View* view) if (m_nScene & LC_SCENE_FLOOR) m_pTerrain->Render(view->mCamera, AspectRatio); - PtrArray OpaquePieces(512); - ObjArray TranslucentSections(512); + lcArray OpaquePieces(512); + lcArray TranslucentSections(512); const lcMatrix44& WorldView = view->mCamera->mWorldView; @@ -1679,7 +1679,7 @@ void Project::RenderScenePieces(View* view) PieceInfo* Info = pPiece->mPieceInfo; if ((Info->mFlags & (LC_PIECE_HAS_SOLID | LC_PIECE_HAS_LINES)) || ((Info->mFlags & LC_PIECE_HAS_DEFAULT) && !Translucent)) - OpaquePieces.AddSorted(pPiece, lcOpaqueRenderCompare, NULL); + OpaquePieces.AddSorted(pPiece, lcOpaqueRenderCompare); if ((Info->mFlags & LC_PIECE_HAS_TRANSLUCENT) || ((Info->mFlags & LC_PIECE_HAS_DEFAULT) && Translucent)) { @@ -1690,7 +1690,7 @@ void Project::RenderScenePieces(View* view) RenderSection.Distance = Pos[2]; RenderSection.piece = pPiece; - TranslucentSections.AddSorted(RenderSection, lcTranslucentRenderCompare, NULL); + TranslucentSections.AddSorted(RenderSection, lcTranslucentRenderCompare); } } @@ -3282,7 +3282,7 @@ void Project::ZoomExtents(int FirstView, int LastView) UpdateAllViews(); } -void Project::GetPiecesUsed(ObjArray& PiecesUsed) const +void Project::GetPiecesUsed(lcArray& PiecesUsed) const { for (Piece* Piece = m_pPieces; Piece; Piece = Piece->m_pNext) { @@ -4478,7 +4478,7 @@ void Project::HandleCommand(LC_COMMANDS id) break; } - ObjArray PiecesUsed; + lcArray PiecesUsed; GetPiecesUsed(PiecesUsed); const char* OldLocale = setlocale(LC_NUMERIC, "C"); @@ -4537,7 +4537,7 @@ void Project::HandleCommand(LC_COMMANDS id) break; } - ObjArray PiecesUsed; + lcArray PiecesUsed; GetPiecesUsed(PiecesUsed); const char* OldLocale = setlocale(LC_NUMERIC, "C"); @@ -7254,7 +7254,7 @@ Object* Project::FindObjectFromPoint(View* view, int x, int y, bool PiecesOnly) return ClickLine.Closest; } -void Project::FindObjectsInBox(float x1, float y1, float x2, float y2, PtrArray& Objects) +void Project::FindObjectsInBox(float x1, float y1, float x2, float y2, lcArray& Objects) { int Viewport[4] = { 0, 0, m_ActiveView->mWidth, m_ActiveView->mHeight }; float Aspect = (float)Viewport[2]/(float)Viewport[3]; @@ -7428,7 +7428,7 @@ bool Project::StopTracking(bool bAccept) if (((float)m_nDownX != m_fTrack[0]) && ((float)m_nDownY != m_fTrack[1])) { // Find objects inside the rectangle. - PtrArray Objects; + lcArray Objects; FindObjectsInBox((float)m_nDownX, (float)m_nDownY, m_fTrack[0], m_fTrack[1], Objects); // Deselect old pieces. @@ -8516,7 +8516,7 @@ void Project::OnLeftButtonDown(View* view) if (CanDelete) { - mCameras.RemovePointer(pCamera); + mCameras.Remove(pCamera); delete pCamera; gMainWindow->UpdateCameraMenu(mCameras, m_ActiveView ? m_ActiveView->mCamera : NULL); diff --git a/common/project.h b/common/project.h index b1b0894e..98426e2e 100644 --- a/common/project.h +++ b/common/project.h @@ -3,7 +3,7 @@ #include "object.h" #include "opengl.h" -#include "array.h" +#include "lc_array.h" #include "lc_math.h" #include "lc_commands.h" @@ -253,7 +253,7 @@ public: void EndPieceDrop(bool Accept); void BeginColorDrop(); - void GetPiecesUsed(ObjArray& PiecesUsed) const; + void GetPiecesUsed(lcArray& PiecesUsed) const; void CreateImages(Image* images, int width, int height, unsigned short from, unsigned short to, bool hilite); void Render(View* view, bool bToMemory); void CheckAutoSave(); @@ -276,7 +276,7 @@ public: // Objects Piece* m_pPieces; - PtrArray mCameras; + lcArray mCameras; Light* m_pLights; Group* m_pGroups; Terrain* m_pTerrain; @@ -288,7 +288,7 @@ public: // Implementation protected: View* m_ActiveView; - PtrArray m_ViewList; + lcArray m_ViewList; char m_strAuthor[101]; char m_strDescription[101]; @@ -309,7 +309,7 @@ protected: void GetPieceInsertPosition(Piece* OffsetPiece, lcVector3& Position, lcVector4& Rotation); void GetPieceInsertPosition(View* view, int MouseX, int MouseY, lcVector3& Position, lcVector4& Orientation); Object* FindObjectFromPoint(View* view, int x, int y, bool PiecesOnly = false); - void FindObjectsInBox(float x1, float y1, float x2, float y2, PtrArray& Objects); + void FindObjectsInBox(float x1, float y1, float x2, float y2, lcArray& Objects); void SelectAndFocusNone(bool bFocusOnly); void CalculateStep(); @@ -426,8 +426,8 @@ protected: bool DoSave(const char* FileName); bool FileLoad(lcFile* file, bool bUndo, bool bMerge); void FileSave(lcFile* file, bool bUndo); - void FileReadLDraw(lcFile* file, const lcMatrix44& CurrentTransform, int* nOk, int DefColor, int* nStep, PtrArray& FileArray); - void FileReadMPD(lcFile& MPD, PtrArray& FileArray) const; + void FileReadLDraw(lcFile* file, const lcMatrix44& CurrentTransform, int* nOk, int DefColor, int* nStep, lcArray& FileArray); + void FileReadMPD(lcFile& MPD, lcArray& FileArray) const; public: // File helpers diff --git a/leocad.pro b/leocad.pro index 6cbb488d..48f98062 100644 --- a/leocad.pro +++ b/leocad.pro @@ -106,7 +106,6 @@ SOURCES += common/view.cpp \ common/curve.cpp \ common/console.cpp \ common/camera.cpp \ - common/array.cpp \ common/lc_profile.cpp \ common/lc_category.cpp \ qt/lc_qmainwindow.cpp \ @@ -138,7 +137,6 @@ SOURCES += common/view.cpp \ qt/lc_qcolorlist.cpp \ qt/lc_qfinddialog.cpp HEADERS += \ - common/array.h \ common/view.h \ common/tr.h \ common/texfont.h \ @@ -197,7 +195,8 @@ HEADERS += \ qt/lc_qglwidget.h \ qt/lc_qcolorlist.h \ common/lc_glwidget.h \ - qt/lc_qfinddialog.h + qt/lc_qfinddialog.h \ + common/lc_array.h FORMS += \ qt/lc_qpovraydialog.ui \ qt/lc_qarraydialog.ui \ diff --git a/qt/lc_qapplication.cpp b/qt/lc_qapplication.cpp index f6b35565..b097c145 100644 --- a/qt/lc_qapplication.cpp +++ b/qt/lc_qapplication.cpp @@ -18,7 +18,7 @@ void lcApplication::ExportClipboard(lcMemFile* Clipboard) SetClipboard(Clipboard); } -void lcApplication::GetFileList(const char* Path, ObjArray& FileList) +void lcApplication::GetFileList(const char* Path, lcArray& FileList) { QDir dir(Path); dir.setFilter(QDir::Files | QDir::Hidden | QDir::Readable); diff --git a/qt/lc_qeditgroupsdialog.cpp b/qt/lc_qeditgroupsdialog.cpp index c314bbc7..78186cc7 100644 --- a/qt/lc_qeditgroupsdialog.cpp +++ b/qt/lc_qeditgroupsdialog.cpp @@ -69,7 +69,7 @@ void lcQEditGroupsDialog::updateParents(QTreeWidgetItem *parentItem, Group *pare { if (itemPiece == piece) { - options->PieceParents.SetAt(pieceIndex, parentGroup); + options->PieceParents[pieceIndex] = parentGroup; break; } } @@ -83,7 +83,7 @@ void lcQEditGroupsDialog::updateParents(QTreeWidgetItem *parentItem, Group *pare { if (itemGroup == group) { - options->GroupParents.SetAt(groupIndex, parentGroup); + options->GroupParents[groupIndex] = parentGroup; break; } } diff --git a/qt/lc_qmainwindow.cpp b/qt/lc_qmainwindow.cpp index ddbdab8b..2606e27f 100644 --- a/qt/lc_qmainwindow.cpp +++ b/qt/lc_qmainwindow.cpp @@ -1203,7 +1203,7 @@ void lcQMainWindow::updateTransformType(int newType) actions[LC_EDIT_TRANSFORM]->setIcon(QIcon(iconNames[newType])); } -void lcQMainWindow::updateCameraMenu(const PtrArray& cameras, Camera* currentCamera) +void lcQMainWindow::updateCameraMenu(const lcArray& cameras, Camera* currentCamera) { int actionIdx, currentIndex = -1; diff --git a/qt/lc_qmainwindow.h b/qt/lc_qmainwindow.h index ba9777af..7521df05 100644 --- a/qt/lc_qmainwindow.h +++ b/qt/lc_qmainwindow.h @@ -3,7 +3,7 @@ #include #include -#include "array.h" +#include "lc_array.h" #include "lc_commands.h" class QComboBox; @@ -41,7 +41,7 @@ public: void updateSnap(); void updateUndoRedo(const char* undoText, const char* redoText); void updateTransformType(int newType); - void updateCameraMenu(const PtrArray& cameras, Camera* currentCamera); + void updateCameraMenu(const lcArray& cameras, Camera* currentCamera); void updateCurrentCamera(int cameraIndex); void updateCategories(); void updateTitle(const char* title, bool modified); diff --git a/qt/lc_qminifigdialog.cpp b/qt/lc_qminifigdialog.cpp index 7e2a91f5..4763074d 100644 --- a/qt/lc_qminifigdialog.cpp +++ b/qt/lc_qminifigdialog.cpp @@ -76,7 +76,7 @@ lcQMinifigDialog::lcQMinifigDialog(QWidget *parent, void *data) : for (int itemIndex = 0; itemIndex < LC_MFW_NUMITEMS; itemIndex++) { - ObjArray& parts = wizard->mSettings[itemIndex]; + lcArray& parts = wizard->mSettings[itemIndex]; QStringList typeList; for (int partIndex = 0; partIndex < parts.GetSize(); partIndex++) diff --git a/qt/lc_qpartstree.cpp b/qt/lc_qpartstree.cpp index f48c159a..9a6e0282 100644 --- a/qt/lc_qpartstree.cpp +++ b/qt/lc_qpartstree.cpp @@ -5,7 +5,7 @@ #include "lc_library.h" #include "pieceinf.h" -static int lcQPartsTreeSortFunc(const PieceInfo* a, const PieceInfo* b, void* sortData) +static int lcQPartsTreeSortFunc(PieceInfo* const& a, PieceInfo* const& b) { if (a->IsSubPiece()) { @@ -65,10 +65,10 @@ void lcQPartsTree::searchParts(const QString& searchString) delete item; lcPiecesLibrary* library = lcGetPiecesLibrary(); - PtrArray singleParts, groupedParts; + lcArray singleParts, groupedParts; library->SearchPieces(searchString.toLocal8Bit().data(), false, singleParts, groupedParts); - singleParts.Sort(lcQPartsTreeSortFunc, NULL); + singleParts.Sort(lcQPartsTreeSortFunc); for (int partIndex = 0; partIndex < singleParts.GetSize(); partIndex++) { @@ -101,12 +101,12 @@ void lcQPartsTree::itemExpanded(QTreeWidgetItem *expandedItem) int categoryIndex = expandedItem->data(0, CategoryRole).toInt(); lcPiecesLibrary* library = lcGetPiecesLibrary(); - PtrArray singleParts, groupedParts; + lcArray singleParts, groupedParts; library->GetCategoryEntries(categoryIndex, true, singleParts, groupedParts); singleParts += groupedParts; - singleParts.Sort(lcQPartsTreeSortFunc, NULL); + singleParts.Sort(lcQPartsTreeSortFunc); for (int partIndex = 0; partIndex < singleParts.GetSize(); partIndex++) { @@ -118,7 +118,7 @@ void lcQPartsTree::itemExpanded(QTreeWidgetItem *expandedItem) if (groupedParts.FindIndex(partInfo) != -1) { - PtrArray patterns; + lcArray patterns; library->GetPatternedPieces(partInfo, patterns); for (int patternIndex = 0; patternIndex < patterns.GetSize(); patternIndex++) diff --git a/qt/lc_qpreferencesdialog.cpp b/qt/lc_qpreferencesdialog.cpp index b22cfb83..72c532c2 100644 --- a/qt/lc_qpreferencesdialog.cpp +++ b/qt/lc_qpreferencesdialog.cpp @@ -181,7 +181,7 @@ void lcQPreferencesDialog::updateParts() if (categoryIndex != -1) { - PtrArray singleParts, groupedParts; + lcArray singleParts, groupedParts; library->SearchPieces(options->Categories[categoryIndex].Keywords, false, singleParts, groupedParts); @@ -295,7 +295,7 @@ void lcQPreferencesDialog::on_importCategories_clicked() char fileName[LC_MAXPATH]; strcpy(fileName, result.toLocal8Bit().data()); - ObjArray categories; + lcArray categories; if (!lcLoadCategories(fileName, categories)) { QMessageBox::warning(this, "LeoCAD", tr("Error loading categories file.")); diff --git a/qt/lc_qpropertiesdialog.cpp b/qt/lc_qpropertiesdialog.cpp index 52fc7da4..d5ec7be4 100644 --- a/qt/lc_qpropertiesdialog.cpp +++ b/qt/lc_qpropertiesdialog.cpp @@ -56,7 +56,7 @@ lcQPropertiesDialog::lcQPropertiesDialog(QWidget *parent, void *data) : ui->ambientColorButton->setIcon(pix); lcPiecesLibrary *library = lcGetPiecesLibrary(); - ObjArray& partsUsed = options->PartsUsed; + lcArray& partsUsed = options->PartsUsed; QStringList horizontalLabels, verticalLabels; int *colorColumns = new int[gNumUserColors], numColors = 0; diff --git a/qt/qtmain.cpp b/qt/qtmain.cpp index 99944311..936aeb25 100644 --- a/qt/qtmain.cpp +++ b/qt/qtmain.cpp @@ -546,7 +546,7 @@ void lcMainWindow::UpdateTransformType(int NewType) window->updateTransformType(NewType); } -void lcMainWindow::UpdateCameraMenu(const PtrArray& Cameras, Camera* CurrentCamera) +void lcMainWindow::UpdateCameraMenu(const lcArray& Cameras, Camera* CurrentCamera) { lcQMainWindow* window = (lcQMainWindow*)mHandle;