mirror of
https://github.com/leozide/leocad
synced 2025-01-28 19:58:12 +01:00
Moved pieces from a linked list to an array.
This commit is contained in:
parent
4fb236d4c4
commit
c5f006cd2c
8 changed files with 521 additions and 444 deletions
|
@ -54,6 +54,11 @@ public:
|
|||
return mData[Index];
|
||||
}
|
||||
|
||||
bool IsEmpty() const
|
||||
{
|
||||
return mLength == 0;
|
||||
}
|
||||
|
||||
int GetSize() const
|
||||
{
|
||||
return mLength;
|
||||
|
|
|
@ -30,7 +30,6 @@ static LC_OBJECT_KEY_INFO piece_key_info[LC_PK_COUNT] =
|
|||
Piece::Piece(PieceInfo* pPieceInfo)
|
||||
: Object (LC_OBJECT_PIECE)
|
||||
{
|
||||
m_pNext = NULL;
|
||||
mPieceInfo = pPieceInfo;
|
||||
m_nState = 0;
|
||||
mColorIndex = 0;
|
||||
|
@ -293,15 +292,19 @@ void Piece::Initialize(float x, float y, float z, unsigned char nStep)
|
|||
UpdatePosition(1);
|
||||
}
|
||||
|
||||
void Piece::CreateName(Piece* pPiece)
|
||||
void Piece::CreateName(const lcArray<Piece*>& Pieces)
|
||||
{
|
||||
int i, max = 0;
|
||||
|
||||
for (; pPiece; pPiece = pPiece->m_pNext)
|
||||
if (strncmp (pPiece->m_strName, mPieceInfo->m_strDescription, strlen(mPieceInfo->m_strDescription)) == 0)
|
||||
if (sscanf(pPiece->m_strName + strlen(mPieceInfo->m_strDescription), " #%d", &i) == 1)
|
||||
for (int PieceIdx = 0; PieceIdx < Pieces.GetSize(); PieceIdx++)
|
||||
{
|
||||
Piece* Piece = Pieces[PieceIdx];
|
||||
|
||||
if (strncmp(Piece->m_strName, mPieceInfo->m_strDescription, strlen(mPieceInfo->m_strDescription)) == 0)
|
||||
if (sscanf(Piece->m_strName + strlen(mPieceInfo->m_strDescription), " #%d", &i) == 1)
|
||||
if (i > max)
|
||||
max = i;
|
||||
}
|
||||
|
||||
sprintf (m_strName, "%s #%.2d", mPieceInfo->m_strDescription, max+1);
|
||||
}
|
||||
|
|
|
@ -35,8 +35,6 @@ public:
|
|||
|
||||
|
||||
|
||||
Piece* m_pNext;
|
||||
|
||||
void Hide()
|
||||
{ m_nState = LC_PIECE_HIDDEN; }
|
||||
void UnHide()
|
||||
|
@ -54,7 +52,7 @@ public:
|
|||
virtual void MinIntersectDist(lcClickLine* ClickLine);
|
||||
bool IsVisible(unsigned short nTime);
|
||||
void Initialize(float x, float y, float z, unsigned char nStep);
|
||||
void CreateName(Piece* pPiece);
|
||||
void CreateName(const lcArray<Piece*>& Pieces);
|
||||
void CompareBoundingBox(float box[6]);
|
||||
void SetPieceInfo(PieceInfo* pPieceInfo);
|
||||
bool FileLoad(lcFile& file);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -298,7 +298,7 @@ public:
|
|||
}
|
||||
|
||||
// Objects
|
||||
Piece* m_pPieces;
|
||||
lcArray<Piece*> mPieces;
|
||||
lcArray<Camera*> mCameras;
|
||||
lcArray<Light*> mLights;
|
||||
Group* m_pGroups;
|
||||
|
|
|
@ -105,15 +105,9 @@ void lcQEditGroupsDialog::updateParents(QTreeWidgetItem *parentItem, Group *pare
|
|||
|
||||
if (itemPiece)
|
||||
{
|
||||
int pieceIndex = 0;
|
||||
for (Piece *piece = project->m_pPieces; piece; piece = piece->m_pNext, pieceIndex++)
|
||||
{
|
||||
if (itemPiece == piece)
|
||||
{
|
||||
options->PieceParents[pieceIndex] = parentGroup;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int pieceIndex = project->mPieces.FindIndex(itemPiece);
|
||||
if (pieceIndex != -1)
|
||||
options->PieceParents[pieceIndex] = parentGroup;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -153,8 +147,10 @@ void lcQEditGroupsDialog::addChildren(QTreeWidgetItem *parentItem, Group *parent
|
|||
addChildren(groupItem, group);
|
||||
}
|
||||
|
||||
for (Piece *piece = project->m_pPieces; piece; piece = piece->m_pNext)
|
||||
for (int pieceIndex = 0; pieceIndex < project->mPieces.GetSize(); pieceIndex++)
|
||||
{
|
||||
Piece *piece = project->mPieces[pieceIndex];
|
||||
|
||||
if (piece->GetGroup() != parentGroup)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ lcQMainWindow::lcQMainWindow(QWidget *parent)
|
|||
|
||||
GL_EnableVertexBufferObject();
|
||||
|
||||
if (lcGetActiveProject()->m_pPieces)
|
||||
if (!lcGetActiveProject()->mPieces.IsEmpty())
|
||||
{
|
||||
for (int PieceIdx = 0; PieceIdx < Library->mPieces.GetSize(); PieceIdx++)
|
||||
{
|
||||
|
|
|
@ -162,8 +162,10 @@ void lcQSelectDialog::addChildren(QTreeWidgetItem *parentItem, Group *parentGrou
|
|||
|
||||
int numObjects = 0;
|
||||
|
||||
for (Piece *piece = project->m_pPieces; piece; piece = piece->m_pNext, numObjects++)
|
||||
for (int pieceIdx = 0; pieceIdx < project->mPieces.GetSize(); pieceIdx++, numObjects++)
|
||||
{
|
||||
Piece *piece = project->mPieces[pieceIdx];
|
||||
|
||||
if (piece->GetGroup() != parentGroup)
|
||||
continue;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue