summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorleo2006-01-03 01:34:03 +0000
committerleo2006-01-03 01:34:03 +0000
commitb463aef5bdc800972f61d9d6ee8087533f011dff (patch)
treee49ca45112cb05a69e83b22dd8f629cb8fadb055 /common
parent43be715ad595e58f3381439c88defb209aa06f89 (diff)
Fixed subpieces in the pieces bar.
git-svn-id: http://svn.leocad.org/trunk@451 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'common')
-rwxr-xr-xcommon/array.cpp30
-rwxr-xr-xcommon/array.h3
-rwxr-xr-xcommon/library.cpp6
-rw-r--r--common/pieceinf.h5
4 files changed, 37 insertions, 7 deletions
diff --git a/common/array.cpp b/common/array.cpp
index 76c9a30..8d1b663 100755
--- a/common/array.cpp
+++ b/common/array.cpp
@@ -121,6 +121,36 @@ int PtrArray<T>::FindIndex(T* Obj) const
}
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;
diff --git a/common/array.h b/common/array.h
index 64f82f9..581d660 100755
--- a/common/array.h
+++ b/common/array.h
@@ -8,7 +8,7 @@ public:
PtrArray(int nSize = 0);
~PtrArray();
- typedef int (*LC_PTRARRAY_COMPARE_FUNC)(T* a, T* b, void* data);
+ typedef int (*LC_PTRARRAY_COMPARE_FUNC)(const T* a, const T* b, void* data);
int GetSize() const
{ return m_nLength; }
@@ -20,6 +20,7 @@ public:
void AddSorted(T* pObj, LC_PTRARRAY_COMPARE_FUNC pFunc, void* pData);
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);
T* operator [](int nIndex) const
diff --git a/common/library.cpp b/common/library.cpp
index e6638e2..adfb3b2 100755
--- a/common/library.cpp
+++ b/common/library.cpp
@@ -533,8 +533,6 @@ int PiecesLibrary::GetFirstCategory(PieceInfo* Info) const
void PiecesLibrary::GetCategoryEntries(int CategoryIndex, bool GroupPieces, PtrArray<PieceInfo>& SinglePieces, PtrArray<PieceInfo>& GroupedPieces) const
{
- bool m_bSubParts = false;
-
SinglePieces.RemoveAll();
GroupedPieces.RemoveAll();
@@ -546,10 +544,6 @@ void PiecesLibrary::GetCategoryEntries(int CategoryIndex, bool GroupPieces, PtrA
{
PieceInfo* Info = &m_pPieceIdx[i];
- // Skip subparts if the user doesn't want to see them.
- if ((Info->m_strDescription[0] == '~') && !m_bSubParts)
- continue;
-
if (!PieceInCategory(Info, m_Categories[CategoryIndex].Keywords))
continue;
diff --git a/common/pieceinf.h b/common/pieceinf.h
index 1124db1..a4ea314 100644
--- a/common/pieceinf.h
+++ b/common/pieceinf.h
@@ -67,6 +67,11 @@ class PieceInfo
return false;
}
+ bool IsSubPiece() const
+ {
+ return (m_strDescription[0] == '~');
+ }
+
// Operations
void ZoomExtents(float Fov, float Aspect);
void RenderOnce(int nColor);