1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

0024762: Visualization - new interactive object AIS_ColoredShape with customized subshapes presentations

AIS_Shape, ::SetColor(), ::SetMaterial(), ::SetTransparency(), ::SetWidth() - improve consistency.
Setup color for marker aspect as well.
vaspects - new command superseeds vsetcolor, vsetmaterial, vsettransparancy, vsetwidth
and their unset analogs. Improve syntax and arguments validation.
OpenGl_AspectMarker::SetAspect() - do not reset myMarkerSize when sprite is unchanged.
Extend NCollection_IndexedDataMap - Iterator::Key() and FindFromKey() with value copying.

Add test case bugs vis bug24762_coloredshape.
This commit is contained in:
kgv
2014-04-03 16:29:23 +04:00
committed by apn
parent 8abada55ca
commit ad3217cd8d
15 changed files with 2012 additions and 825 deletions

View File

@@ -104,15 +104,18 @@ template < class TheKeyType,
myMap(NULL),
myIndex(0) {}
//! Constructor
Iterator (const NCollection_IndexedDataMap& theMap) :
myMap((NCollection_IndexedDataMap *) &theMap),
myIndex(1) {}
Iterator (const NCollection_IndexedDataMap& theMap)
: myMap ((NCollection_IndexedDataMap* )&theMap),
myNode (myMap->nodeFromIndex (1)),
myIndex (1) {}
//! Query if the end of collection is reached by iterator
virtual Standard_Boolean More(void) const
{ return (myIndex <= myMap->Extent()); }
//! Make a step along the collection
virtual void Next(void)
{ myIndex++; }
{
myNode = myMap->nodeFromIndex (++myIndex);
}
//! Value access
virtual const TheItemType& Value(void) const
{
@@ -120,7 +123,7 @@ template < class TheKeyType,
if (!More())
Standard_NoSuchObject::Raise("NCollection_IndexedDataMap::Iterator::Value");
#endif
return myMap->FindFromIndex(myIndex);
return myNode->Value();
}
//! ChangeValue access
virtual TheItemType& ChangeValue(void) const
@@ -129,12 +132,21 @@ template < class TheKeyType,
if (!More())
Standard_NoSuchObject::Raise("NCollection_IndexedDataMap::Iterator::ChangeValue");
#endif
return myMap->ChangeFromIndex(myIndex);
return myNode->ChangeValue();
}
//! Key
const TheKeyType& Key() const
{
#if !defined No_Exception && !defined No_Standard_NoSuchObject
if (!More())
Standard_NoSuchObject::Raise("NCollection_DataMap::Iterator::Key");
#endif
return myNode->Key1();
}
private:
NCollection_IndexedDataMap * myMap; //!< Pointer to the map being iterated
Standard_Integer myIndex; //!< Current index
NCollection_IndexedDataMap* myMap; //!< Pointer to the map being iterated
IndexedDataMapNode* myNode; //!< Current node
Standard_Integer myIndex; //!< Current index
};
public:
@@ -365,16 +377,12 @@ template < class TheKeyType,
if (theKey2 < 1 || theKey2 > Extent())
Standard_OutOfRange::Raise ("NCollection_IndexedDataMap::FindKey");
#endif
IndexedDataMapNode * pNode2 =
(IndexedDataMapNode *) myData2[::HashCode(theKey2,NbBuckets())];
while (pNode2)
IndexedDataMapNode* aNode = nodeFromIndex (theKey2);
if (aNode == NULL)
{
if (pNode2->Key2() == theKey2)
return pNode2->Key1();
pNode2 = (IndexedDataMapNode*) pNode2->Next2();
Standard_NoSuchObject::Raise ("NCollection_IndexedDataMap::FindKey");
}
Standard_NoSuchObject::Raise("NCollection_IndexedDataMap::FindKey");
return pNode2->Key1(); // This for compiler
return aNode->Key1();
}
//! FindFromIndex
@@ -384,16 +392,12 @@ template < class TheKeyType,
if (theKey2 < 1 || theKey2 > Extent())
Standard_OutOfRange::Raise ("NCollection_IndexedDataMap::FindFromIndex");
#endif
IndexedDataMapNode * pNode2 =
(IndexedDataMapNode *) myData2[::HashCode(theKey2,NbBuckets())];
while (pNode2)
IndexedDataMapNode* aNode = nodeFromIndex (theKey2);
if (aNode == NULL)
{
if (pNode2->Key2() == theKey2)
return pNode2->Value();
pNode2 = (IndexedDataMapNode*) pNode2->Next2();
Standard_NoSuchObject::Raise ("NCollection_IndexedDataMap::FindFromIndex");
}
Standard_NoSuchObject::Raise("NCollection_IndexedDataMap::FindFromIndex");
return pNode2->Value(); // This for compiler
return aNode->Value();
}
//! operator ()
@@ -407,16 +411,12 @@ template < class TheKeyType,
if (theKey2 < 1 || theKey2 > Extent())
Standard_OutOfRange::Raise("NCollection_IndexedDataMap::ChangeFromIndex");
#endif
IndexedDataMapNode * pNode2 =
(IndexedDataMapNode *) myData2[::HashCode(theKey2,NbBuckets())];
while (pNode2)
IndexedDataMapNode* aNode = nodeFromIndex (theKey2);
if (aNode == NULL)
{
if (pNode2->Key2() == theKey2)
return pNode2->ChangeValue();
pNode2 = (IndexedDataMapNode*) pNode2->Next2();
Standard_NoSuchObject::Raise ("NCollection_IndexedDataMap::ChangeFromIndex");
}
Standard_NoSuchObject::Raise("NCollection_IndexedDataMap::FindFromIndex");
return pNode2->ChangeValue(); // This for compiler
return aNode->ChangeValue();
}
//! operator ()
@@ -476,6 +476,27 @@ template < class TheKeyType,
return pNode1->ChangeValue();
}
//! Find value for key with copying.
//! @return true if key was found
Standard_Boolean FindFromKey (const TheKeyType& theKey1,
TheItemType& theValue) const
{
if (IsEmpty())
{
return Standard_False;
}
for (IndexedDataMapNode* aNode = (IndexedDataMapNode* )myData1[Hasher::HashCode (theKey1, NbBuckets())];
aNode != NULL; aNode = (IndexedDataMapNode* )aNode->Next())
{
if (Hasher::IsEqual (aNode->Key1(), theKey1))
{
theValue = aNode->Value();
return Standard_True;
}
}
return Standard_False;
}
//! Clear data. If doReleaseMemory is false then the table of
//! buckets is not released and will be reused.
void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
@@ -505,6 +526,25 @@ template < class TheKeyType,
CreateIterator(void) const
{ return *(new (this->IterAllocator()) Iterator(*this)); }
//! Find map node associated with specified index.
//! Return NULL if not found (exception-free internal implementation).
IndexedDataMapNode* nodeFromIndex (const Standard_Integer theKey2) const
{
if (Extent() == 0)
{
return NULL;
}
for (IndexedDataMapNode* aNode = (IndexedDataMapNode* )myData2[::HashCode (theKey2, NbBuckets())];
aNode != NULL; aNode = (IndexedDataMapNode* )aNode->Next2())
{
if (aNode->Key2() == theKey2)
{
return aNode;
}
}
return NULL;
}
};
#endif