Array class cleanup.

This commit is contained in:
leo 2013-08-15 23:43:18 +00:00
parent ad7ffb3cf0
commit 979217d023
31 changed files with 311 additions and 608 deletions

View file

@ -1,402 +0,0 @@
//
// Simple array classes
//
#include <stdlib.h>
#include <string.h>
template <class T>
PtrArray<T>::PtrArray(int nSize)
{
m_pData = NULL;
m_nLength = 0;
m_nAlloc = 0;
if(nSize != 0)
Expand(nSize);
}
template <class T>
PtrArray<T>::~PtrArray()
{
free(m_pData);
}
template <class T>
void PtrArray<T>::SetSize(int Size)
{
if (Size > m_nLength)
Expand(Size - m_nLength);
m_nLength = Size;
}
template <class T>
void PtrArray<T>::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 <class T>
void PtrArray<T>::RemoveAll()
{
m_nLength = 0;
}
template <class T>
T* PtrArray<T>::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 <class T>
T* PtrArray<T>::RemovePointer(T* pObj)
{
int i;
for(i = 0; i < m_nLength; i++)
if(m_pData[i] == pObj)
return RemoveIndex(i);
return NULL;
}
template <class T>
void PtrArray<T>::Add(T* pObj)
{
Expand(1);
m_pData[m_nLength] = pObj;
m_nLength++;
}
template <class T>
void PtrArray<T>::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 <class T>
void PtrArray<T>::SetAt(int Index, T* Ptr)
{
m_pData[Index] = Ptr;
}
template <class T>
void PtrArray<T>::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 <class T>
int PtrArray<T>::FindIndex(T* Obj) const
{
for (int i = 0; i < m_nLength; i++)
if (m_pData[i] == Obj)
return i;
return -1;
}
template <class T>
void PtrArray<T>::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 <class T>
PtrArray<T>& PtrArray<T>::operator=(const PtrArray<T>& 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 <class T>
PtrArray<T>& PtrArray<T>::operator+=(const PtrArray<T>& 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 <class T>
ObjArray<T>::ObjArray(int Size, int Grow)
{
m_Data = NULL;
m_Length = 0;
m_Alloc = 0;
m_Grow = Grow;
if (Size != 0)
Expand(Size);
}
template <class T>
ObjArray<T>::~ObjArray ()
{
delete[] m_Data;
}
template <class T>
void ObjArray<T>::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 <class T>
void ObjArray<T>::RemoveAll()
{
m_Length = 0;
}
template <class T>
void ObjArray<T>::RemoveIndex(int Index)
{
m_Length--;
for (int i = Index; i < m_Length; i++)
m_Data[i] = m_Data[i+1];
}
template <class T>
void ObjArray<T>::SetSize(int NewSize)
{
if (NewSize > m_Alloc)
Expand(NewSize - m_Alloc);
m_Length = NewSize;
}
template <class T>
void ObjArray<T>::Add(const T& Obj)
{
Expand(1);
m_Data[m_Length++] = Obj;
}
template <class T>
T& ObjArray<T>::Add()
{
Expand(1);
return m_Data[m_Length++];
}
template <class T>
void ObjArray<T>::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 <class T>
void ObjArray<T>::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 <class T>
void ObjArray<T>::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;
}
*/

View file

@ -1,88 +0,0 @@
#ifndef _ARRAY_H_
#define _ARRAY_H_
template <class T>
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<T>& operator=(const PtrArray<T>& Array);
PtrArray<T>& operator+=(const PtrArray<T>& Array);
T* operator [](int nIndex) const
{ return m_pData[nIndex]; }
protected:
T** m_pData;
int m_nLength;
int m_nAlloc;
};
template <class T>
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<T>& operator=(const ObjArray<T>& 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_

View file

@ -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<lcPiecesUsedEntry> PartsUsed;
lcArray<lcPiecesUsedEntry> PartsUsed;
};
struct lcArrayDialogOptions
@ -129,13 +129,13 @@ struct lcArrayDialogOptions
struct lcEditGroupsDialogOptions
{
PtrArray<Group> PieceParents;
PtrArray<Group> GroupParents;
lcArray<Group*> PieceParents;
lcArray<Group*> GroupParents;
};
struct lcSelectDialogOptions
{
ObjArray<bool> Selection;
lcArray<bool> Selection;
};
struct lcPreferencesDialogOptions
@ -152,7 +152,7 @@ struct lcPreferencesDialogOptions
int AASamples;
int GridSize;
ObjArray<lcLibraryCategory> Categories;
lcArray<lcLibraryCategory> Categories;
bool CategoriesModified;
bool CategoriesDefault;

View file

@ -164,7 +164,7 @@ void Camera::Initialize()
m_pTarget = new CameraTarget(this);
}
void Camera::CreateName(const PtrArray<Camera>& Cameras)
void Camera::CreateName(const lcArray<Camera*>& Cameras)
{
int i, max = 0;
const char* Prefix = "Camera ";

View file

@ -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<Camera>& Cameras);
void CreateName(const lcArray<Camera*>& Cameras);
CameraTarget* GetTarget() const
{

View file

@ -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<CurvePoint> m_Points;
lcArray<CurvePoint*> m_Points;
};
#endif
#endif // _CURVE_H_

View file

@ -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<String>& FileList);
void GetFileList(const char* Path, lcArray<String>& FileList);
void OpenURL(const char* URL);
void SetClipboard(lcFile* Clipboard);
void ExportClipboard(lcMemFile* Clipboard);

195
common/lc_array.h Normal file
View file

@ -0,0 +1,195 @@
#ifndef _LC_ARRAY_H_
#define _LC_ARRAY_H_
template <class T>
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<T>& operator=(const lcArray<T>& 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<T>& operator+=(const lcArray<T>& 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_

View file

@ -3,7 +3,7 @@
#include "lc_file.h"
#include "lc_profile.h"
ObjArray<lcLibraryCategory> gCategories;
lcArray<lcLibraryCategory> gCategories;
void lcResetDefaultCategories()
{
@ -31,7 +31,7 @@ void lcSaveDefaultCategories()
lcSetProfileBuffer(LC_PROFILE_CATEGORIES, File);
}
void lcResetCategories(ObjArray<lcLibraryCategory>& Categories, bool BuiltInLibrary)
void lcResetCategories(lcArray<lcLibraryCategory>& Categories, bool BuiltInLibrary)
{
const char DefaultCategories[] =
{
@ -86,7 +86,7 @@ void lcResetCategories(ObjArray<lcLibraryCategory>& Categories, bool BuiltInLibr
lcLoadCategories(File, Categories);
}
bool lcLoadCategories(const char* FileName, ObjArray<lcLibraryCategory>& Categories)
bool lcLoadCategories(const char* FileName, lcArray<lcLibraryCategory>& Categories)
{
lcDiskFile File;
@ -96,7 +96,7 @@ bool lcLoadCategories(const char* FileName, ObjArray<lcLibraryCategory>& Categor
return lcLoadCategories(File, Categories);
}
bool lcLoadCategories(lcFile& File, ObjArray<lcLibraryCategory>& Categories)
bool lcLoadCategories(lcFile& File, lcArray<lcLibraryCategory>& Categories)
{
Categories.RemoveAll();
@ -125,7 +125,7 @@ bool lcLoadCategories(lcFile& File, ObjArray<lcLibraryCategory>& Categories)
return true;
}
bool lcSaveCategories(const char* FileName, const ObjArray<lcLibraryCategory>& Categories)
bool lcSaveCategories(const char* FileName, const lcArray<lcLibraryCategory>& Categories)
{
lcDiskFile File;
@ -135,7 +135,7 @@ bool lcSaveCategories(const char* FileName, const ObjArray<lcLibraryCategory>& C
return lcSaveCategories(File, Categories);
}
bool lcSaveCategories(lcFile& File, const ObjArray<lcLibraryCategory>& Categories)
bool lcSaveCategories(lcFile& File, const lcArray<lcLibraryCategory>& Categories)
{
char Line[1024];

View file

@ -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<lcLibraryCategory> gCategories;
extern lcArray<lcLibraryCategory> gCategories;
void lcResetDefaultCategories();
void lcLoadDefaultCategories(bool BuiltInLibrary = false);
void lcSaveDefaultCategories();
void lcResetCategories(ObjArray<lcLibraryCategory>& Categories, bool BuiltInLibrary = false);
bool lcLoadCategories(const char* FileName, ObjArray<lcLibraryCategory>& Categories);
bool lcLoadCategories(lcFile& File, ObjArray<lcLibraryCategory>& Categories);
bool lcSaveCategories(const char* FileName, const ObjArray<lcLibraryCategory>& Categories);
bool lcSaveCategories(lcFile& File, const ObjArray<lcLibraryCategory>& Categories);
void lcResetCategories(lcArray<lcLibraryCategory>& Categories, bool BuiltInLibrary = false);
bool lcLoadCategories(const char* FileName, lcArray<lcLibraryCategory>& Categories);
bool lcLoadCategories(lcFile& File, lcArray<lcLibraryCategory>& Categories);
bool lcSaveCategories(const char* FileName, const lcArray<lcLibraryCategory>& Categories);
bool lcSaveCategories(lcFile& File, const lcArray<lcLibraryCategory>& Categories);
#endif // _LC_CATEGORY_H_

View file

@ -3,7 +3,7 @@
#include "lc_file.h"
#include <float.h>
ObjArray<lcColor> gColorList;
lcArray<lcColor> 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<lcColor>& Colors = gColorList;
lcArray<lcColor>& Colors = gColorList;
lcColor Color, MainColor, EdgeColor;
Colors.RemoveAll();

View file

@ -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<int> Colors;
lcArray<int> Colors;
char Name[LC_MAX_COLOR_NAME];
};
extern ObjArray<lcColor> gColorList;
extern lcArray<lcColor> gColorList;
extern lcColorGroup gColorGroups[LC_NUM_COLORGROUPS];
extern int gNumUserColors;
extern int gEdgeColor;

View file

@ -301,7 +301,7 @@ bool lcPiecesLibrary::OpenDirectory(const char* Path)
Unload();
char FileName[LC_MAXPATH];
ObjArray<String> FileList;
lcArray<String> 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<lcLibraryTextureMap> TextureStack;
lcArray<lcLibraryTextureMap> 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<lcLibraryTextureMap> TextureStack;
lcArray<lcLibraryTextureMap> 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<lcLibraryTextureMap>& TextureStack, lcLibraryMeshData& MeshData)
bool lcPiecesLibrary::ReadMeshData(lcFile& File, const lcMatrix44& CurrentTransform, lcuint32 CurrentColorCode, lcArray<lcLibraryTextureMap>& 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<lcuint32> IndexRemap(VertexCount);
lcArray<lcuint32> 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<lcuint32> TexturedIndexRemap(TexturedVertexCount);
lcArray<lcuint32> 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<PieceInfo>& SinglePieces, PtrArray<PieceInfo>& GroupedPieces)
void lcPiecesLibrary::GetCategoryEntries(int CategoryIndex, bool GroupPieces, lcArray<PieceInfo*>& SinglePieces, lcArray<PieceInfo*>& 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<PieceInfo>& SinglePieces, PtrArray<PieceInfo>& GroupedPieces)
void lcPiecesLibrary::SearchPieces(const String& CategoryKeywords, bool GroupPieces, lcArray<PieceInfo*>& SinglePieces, lcArray<PieceInfo*>& GroupedPieces)
{
SinglePieces.RemoveAll();
GroupedPieces.RemoveAll();
@ -1877,7 +1877,7 @@ void lcPiecesLibrary::SearchPieces(const String& CategoryKeywords, bool GroupPie
}
}
void lcPiecesLibrary::GetPatternedPieces(PieceInfo* Parent, PtrArray<PieceInfo>& Pieces) const
void lcPiecesLibrary::GetPatternedPieces(PieceInfo* Parent, lcArray<PieceInfo*>& Pieces) const
{
char Name[LC_PIECE_NAME_LEN];
strcpy(Name, Parent->m_strName);

View file

@ -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<lcuint32> mIndices;
lcArray<lcuint32> 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<lcLibraryMeshSection> mSections;
ObjArray<lcVertex> mVertices;
ObjArray<lcVertexTextured> mTexturedVertices;
lcArray<lcLibraryMeshSection*> mSections;
lcArray<lcVertex> mVertices;
lcArray<lcVertexTextured> 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<PieceInfo>& SinglePieces, PtrArray<PieceInfo>& GroupedPieces);
void GetCategoryEntries(int CategoryIndex, bool GroupPieces, PtrArray<PieceInfo>& SinglePieces, PtrArray<PieceInfo>& GroupedPieces);
void GetPatternedPieces(PieceInfo* Parent, PtrArray<PieceInfo>& Pieces) const;
void SearchPieces(const String& CategoryKeywords, bool GroupPieces, lcArray<PieceInfo*>& SinglePieces, lcArray<PieceInfo*>& GroupedPieces);
void GetCategoryEntries(int CategoryIndex, bool GroupPieces, lcArray<PieceInfo*>& SinglePieces, lcArray<PieceInfo*>& GroupedPieces);
void GetPatternedPieces(PieceInfo* Parent, lcArray<PieceInfo*>& Pieces) const;
PtrArray<PieceInfo> mPieces;
PtrArray<lcLibraryPrimitive> mPrimitives;
lcArray<PieceInfo*> mPieces;
lcArray<lcLibraryPrimitive*> mPrimitives;
int mNumOfficialPieces;
PtrArray<lcTexture> mTextures;
lcArray<lcTexture*> 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<lcLibraryTextureMap>& TextureStack, lcLibraryMeshData& MeshData);
bool ReadMeshData(lcFile& File, const lcMatrix44& CurrentTransform, lcuint32 CurrentColorCode, lcArray<lcLibraryTextureMap>& TextureStack, lcLibraryMeshData& MeshData);
char mCacheFileName[LC_MAXPATH];
lcuint64 mCacheFileModifiedTime;

View file

@ -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++)
{

View file

@ -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<lcZipFileInfo> mFiles;
lcArray<lcZipFileInfo> mFiles;
protected:
bool Open();

View file

@ -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<Camera>& Cameras, Camera* CurrentCamera);
void UpdateCameraMenu(const lcArray<Camera*>& Cameras, Camera* CurrentCamera);
void UpdateCategories();
void UpdateTitle(const char* Title, bool Modified);
void UpdateModified(bool Modified);

View file

@ -934,7 +934,7 @@ void MinifigWizard::ParseSettings(lcFile& Settings)
for (int SectionIndex = 0; SectionIndex < LC_MFW_NUMITEMS; SectionIndex++)
{
ObjArray<lcMinifigPieceInfo>& InfoArray = mSettings[SectionIndex];
lcArray<lcMinifigPieceInfo>& 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<lcMinifigPieceInfo>& InfoArray = mSettings[Type];
const lcArray<lcMinifigPieceInfo>& InfoArray = mSettings[Type];
for (int Index = 0; Index < InfoArray.GetSize(); Index++)
if (InfoArray[Index].Info == mMinifig->Parts[Type])

View file

@ -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<lcMinifigPieceInfo> mSettings[LC_MFW_NUMITEMS];
lcArray<lcMinifigPieceInfo> mSettings[LC_MFW_NUMITEMS];
lcMinifig* mMinifig;

View file

@ -863,7 +863,7 @@ void Project::FileSave(lcFile* file, bool bUndo)
}
}
void Project::FileReadMPD(lcFile& MPD, PtrArray<LC_FILEENTRY>& FileArray) const
void Project::FileReadMPD(lcFile& MPD, lcArray<LC_FILEENTRY*>& FileArray) const
{
LC_FILEENTRY* CurFile = NULL;
char Buf[1024];
@ -911,7 +911,7 @@ void Project::FileReadMPD(lcFile& MPD, PtrArray<LC_FILEENTRY>& FileArray) const
}
}
void Project::FileReadLDraw(lcFile* file, const lcMatrix44& CurrentTransform, int* nOk, int DefColor, int* nStep, PtrArray<LC_FILEENTRY>& FileArray)
void Project::FileReadLDraw(lcFile* file, const lcMatrix44& CurrentTransform, int* nOk, int DefColor, int* nStep, lcArray<LC_FILEENTRY*>& FileArray)
{
char buf[1024];
@ -1280,7 +1280,7 @@ bool Project::OnOpenDocument (const char* lpszPathName)
if (file.GetLength() != 0)
{
PtrArray<LC_FILEENTRY> FileArray;
lcArray<LC_FILEENTRY*> 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<Piece> OpaquePieces(512);
ObjArray<lcTranslucentRenderSection> TranslucentSections(512);
lcArray<Piece*> OpaquePieces(512);
lcArray<lcTranslucentRenderSection> 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<lcPiecesUsedEntry>& PiecesUsed) const
void Project::GetPiecesUsed(lcArray<lcPiecesUsedEntry>& PiecesUsed) const
{
for (Piece* Piece = m_pPieces; Piece; Piece = Piece->m_pNext)
{
@ -4478,7 +4478,7 @@ void Project::HandleCommand(LC_COMMANDS id)
break;
}
ObjArray<lcPiecesUsedEntry> PiecesUsed;
lcArray<lcPiecesUsedEntry> PiecesUsed;
GetPiecesUsed(PiecesUsed);
const char* OldLocale = setlocale(LC_NUMERIC, "C");
@ -4537,7 +4537,7 @@ void Project::HandleCommand(LC_COMMANDS id)
break;
}
ObjArray<lcPiecesUsedEntry> PiecesUsed;
lcArray<lcPiecesUsedEntry> 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<Object>& Objects)
void Project::FindObjectsInBox(float x1, float y1, float x2, float y2, lcArray<Object*>& 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<Object> Objects;
lcArray<Object*> 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);

View file

@ -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<lcPiecesUsedEntry>& PiecesUsed) const;
void GetPiecesUsed(lcArray<lcPiecesUsedEntry>& 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<Camera> mCameras;
lcArray<Camera*> mCameras;
Light* m_pLights;
Group* m_pGroups;
Terrain* m_pTerrain;
@ -288,7 +288,7 @@ public:
// Implementation
protected:
View* m_ActiveView;
PtrArray<View> m_ViewList;
lcArray<View*> 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<Object>& Objects);
void FindObjectsInBox(float x1, float y1, float x2, float y2, lcArray<Object*>& 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<LC_FILEENTRY>& FileArray);
void FileReadMPD(lcFile& MPD, PtrArray<LC_FILEENTRY>& FileArray) const;
void FileReadLDraw(lcFile* file, const lcMatrix44& CurrentTransform, int* nOk, int DefColor, int* nStep, lcArray<LC_FILEENTRY*>& FileArray);
void FileReadMPD(lcFile& MPD, lcArray<LC_FILEENTRY*>& FileArray) const;
public:
// File helpers

View file

@ -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 \

View file

@ -18,7 +18,7 @@ void lcApplication::ExportClipboard(lcMemFile* Clipboard)
SetClipboard(Clipboard);
}
void lcApplication::GetFileList(const char* Path, ObjArray<String>& FileList)
void lcApplication::GetFileList(const char* Path, lcArray<String>& FileList)
{
QDir dir(Path);
dir.setFilter(QDir::Files | QDir::Hidden | QDir::Readable);

View file

@ -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;
}
}

View file

@ -1203,7 +1203,7 @@ void lcQMainWindow::updateTransformType(int newType)
actions[LC_EDIT_TRANSFORM]->setIcon(QIcon(iconNames[newType]));
}
void lcQMainWindow::updateCameraMenu(const PtrArray<Camera>& cameras, Camera* currentCamera)
void lcQMainWindow::updateCameraMenu(const lcArray<Camera*>& cameras, Camera* currentCamera)
{
int actionIdx, currentIndex = -1;

View file

@ -3,7 +3,7 @@
#include <QMainWindow>
#include <QPrinter>
#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<Camera>& cameras, Camera* currentCamera);
void updateCameraMenu(const lcArray<Camera*>& cameras, Camera* currentCamera);
void updateCurrentCamera(int cameraIndex);
void updateCategories();
void updateTitle(const char* title, bool modified);

View file

@ -76,7 +76,7 @@ lcQMinifigDialog::lcQMinifigDialog(QWidget *parent, void *data) :
for (int itemIndex = 0; itemIndex < LC_MFW_NUMITEMS; itemIndex++)
{
ObjArray<lcMinifigPieceInfo>& parts = wizard->mSettings[itemIndex];
lcArray<lcMinifigPieceInfo>& parts = wizard->mSettings[itemIndex];
QStringList typeList;
for (int partIndex = 0; partIndex < parts.GetSize(); partIndex++)

View file

@ -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<PieceInfo> singleParts, groupedParts;
lcArray<PieceInfo*> 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<PieceInfo> singleParts, groupedParts;
lcArray<PieceInfo*> 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<PieceInfo> patterns;
lcArray<PieceInfo*> patterns;
library->GetPatternedPieces(partInfo, patterns);
for (int patternIndex = 0; patternIndex < patterns.GetSize(); patternIndex++)

View file

@ -181,7 +181,7 @@ void lcQPreferencesDialog::updateParts()
if (categoryIndex != -1)
{
PtrArray<PieceInfo> singleParts, groupedParts;
lcArray<PieceInfo*> 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<lcLibraryCategory> categories;
lcArray<lcLibraryCategory> categories;
if (!lcLoadCategories(fileName, categories))
{
QMessageBox::warning(this, "LeoCAD", tr("Error loading categories file."));

View file

@ -56,7 +56,7 @@ lcQPropertiesDialog::lcQPropertiesDialog(QWidget *parent, void *data) :
ui->ambientColorButton->setIcon(pix);
lcPiecesLibrary *library = lcGetPiecesLibrary();
ObjArray<lcPiecesUsedEntry>& partsUsed = options->PartsUsed;
lcArray<lcPiecesUsedEntry>& partsUsed = options->PartsUsed;
QStringList horizontalLabels, verticalLabels;
int *colorColumns = new int[gNumUserColors], numColors = 0;

View file

@ -546,7 +546,7 @@ void lcMainWindow::UpdateTransformType(int NewType)
window->updateTransformType(NewType);
}
void lcMainWindow::UpdateCameraMenu(const PtrArray<Camera>& Cameras, Camera* CurrentCamera)
void lcMainWindow::UpdateCameraMenu(const lcArray<Camera*>& Cameras, Camera* CurrentCamera)
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;