mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-05-16 10:54:53 +03:00
Storage the parts transparency in the view
This commit is contained in:
parent
d93ae7ffe5
commit
aee5a1b3f6
@ -250,6 +250,16 @@ Standard_GUID XCAFDoc::ViewRefPlaneGUID()
|
||||
return ID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ViewRefPlaneGUID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_GUID XCAFDoc::ViewRefEnabledShapesGUID()
|
||||
{
|
||||
static Standard_GUID ID("efd213e4-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return ID;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : LockGUID
|
||||
//purpose :
|
||||
|
@ -120,6 +120,9 @@ public:
|
||||
|
||||
//! Return GUIDs for TreeNode representing specified types of View
|
||||
Standard_EXPORT static Standard_GUID ViewRefPlaneGUID();
|
||||
|
||||
//! Return GUIDs for TreeNode representing specified types of View
|
||||
Standard_EXPORT static Standard_GUID ViewRefEnabledShapesGUID();
|
||||
|
||||
//! Returns GUID for UAttribute identifying lock flag
|
||||
Standard_EXPORT static Standard_GUID LockGUID();
|
||||
|
@ -46,7 +46,8 @@ enum ChildLab
|
||||
ChildLab_BackPlaneDistance,
|
||||
ChildLab_ViewVolumeSidesClipping,
|
||||
ChildLab_GDTPoints,
|
||||
ChildLab_Image
|
||||
ChildLab_Image,
|
||||
ChildLab_EnabledShapes
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
@ -155,6 +156,15 @@ void XCAFDoc_View::SetObject (const Handle(XCAFView_Object)& theObject)
|
||||
arr->SetValue(i, image->Value(i));
|
||||
}
|
||||
}
|
||||
//shapes transparency
|
||||
if (theObject->HasEnabledShapes())
|
||||
{
|
||||
TDF_Label aShapeTranspLabel = Label().FindChild(ChildLab_EnabledShapes);
|
||||
for (Standard_Integer i = 1; i <= theObject->NbEnabledShapes(); i++) {
|
||||
Standard_Integer aValue = theObject->EnabledShape(i) ? 1 : 0;
|
||||
TDataStd_Integer::Set(aShapeTranspLabel.FindChild(i), aValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -263,6 +273,19 @@ Handle(XCAFView_Object) XCAFDoc_View::GetObject() const
|
||||
if (Label().FindChild(ChildLab_Image).FindAttribute(TDataStd_ByteArray::GetID(), anArr)) {
|
||||
anObj->SetImage(anArr->InternalArray());
|
||||
}
|
||||
|
||||
// Shapes transparency
|
||||
if (!Label().FindChild(ChildLab_EnabledShapes, Standard_False).IsNull()) {
|
||||
TDF_Label aShapesTranspLabel = Label().FindChild(ChildLab_EnabledShapes);
|
||||
anObj->CreateEnabledShapes(aShapesTranspLabel.NbChildren());
|
||||
for (Standard_Integer i = 1; i <= aShapesTranspLabel.NbChildren(); i++) {
|
||||
gp_Pnt aPoint;
|
||||
Handle(TDataStd_Integer) aTranspAttr;
|
||||
aShapesTranspLabel.FindChild(i).FindAttribute(TDataStd_Integer::GetID(), aTranspAttr);
|
||||
Standard_Boolean aValue = (aTranspAttr->Get() == 1);
|
||||
anObj->SetEnabledShape(i, aValue);
|
||||
}
|
||||
}
|
||||
return anObj;
|
||||
}
|
||||
|
||||
|
@ -318,6 +318,46 @@ void XCAFDoc_ViewTool::SetClippingPlanes(const TDF_LabelSequence& theClippingPla
|
||||
aChGNode->SetFather(aPlaneGNode);
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
//function : SetEnabledShapes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_ViewTool::SetEnabledShapes(const TDF_LabelSequence& theShapesTransparencyLabels,
|
||||
const TDF_Label& theViewL) const
|
||||
{
|
||||
if (!IsView(theViewL))
|
||||
return;
|
||||
|
||||
Handle(XCAFDoc_GraphNode) aChGNode;
|
||||
Handle(XCAFDoc_GraphNode) aPlaneGNode;
|
||||
|
||||
if (theViewL.FindAttribute(XCAFDoc::ViewRefEnabledShapesGUID(), aChGNode)) {
|
||||
while (aChGNode->NbFathers() > 0) {
|
||||
aPlaneGNode = aChGNode->GetFather(1);
|
||||
aPlaneGNode->UnSetChild(aChGNode);
|
||||
if (aPlaneGNode->NbChildren() == 0)
|
||||
aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefEnabledShapesGUID());
|
||||
}
|
||||
theViewL.ForgetAttribute(XCAFDoc::ViewRefEnabledShapesGUID());
|
||||
}
|
||||
|
||||
|
||||
if (!theViewL.FindAttribute(XCAFDoc::ViewRefEnabledShapesGUID(), aChGNode) && theShapesTransparencyLabels.Length() > 0) {
|
||||
aChGNode = new XCAFDoc_GraphNode;
|
||||
aChGNode = XCAFDoc_GraphNode::Set(theViewL);
|
||||
aChGNode->SetGraphID(XCAFDoc::ViewRefEnabledShapesGUID());
|
||||
}
|
||||
for (Standard_Integer i = theShapesTransparencyLabels.Lower(); i <= theShapesTransparencyLabels.Upper(); i++)
|
||||
{
|
||||
if (!theShapesTransparencyLabels.Value(i).FindAttribute(XCAFDoc::ViewRefEnabledShapesGUID(), aPlaneGNode)) {
|
||||
aPlaneGNode = new XCAFDoc_GraphNode;
|
||||
aPlaneGNode = XCAFDoc_GraphNode::Set(theShapesTransparencyLabels.Value(i));
|
||||
}
|
||||
aPlaneGNode->SetGraphID(XCAFDoc::ViewRefEnabledShapesGUID());
|
||||
aPlaneGNode->SetChild(aChGNode);
|
||||
aChGNode->SetFather(aPlaneGNode);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetRefShapeLabel
|
||||
@ -391,6 +431,30 @@ Standard_Boolean XCAFDoc_ViewTool::GetRefClippingPlaneLabel(const TDF_Label& the
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetRefEnabledShapesLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean XCAFDoc_ViewTool::GetRefEnabledShapesLabel(const TDF_Label& theViewL,
|
||||
TDF_LabelSequence& theShapesTranspanencyLabels) const
|
||||
{
|
||||
theShapesTranspanencyLabels.Clear();
|
||||
Handle(TDataStd_TreeNode) aNode;
|
||||
if (!theViewL.FindAttribute(XCAFDoc::ViewRefGUID(), aNode) || !aNode->HasFather()) {
|
||||
Handle(XCAFDoc_GraphNode) aGNode;
|
||||
if (theViewL.FindAttribute(XCAFDoc::ViewRefEnabledShapesGUID(), aGNode) && aGNode->NbFathers() > 0) {
|
||||
for (Standard_Integer i = 1; i <= aGNode->NbFathers(); i++)
|
||||
theShapesTranspanencyLabels.Append(aGNode->GetFather(i)->Label());
|
||||
return Standard_True;
|
||||
}
|
||||
else
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theShapesTranspanencyLabels.Append(aNode->Father()->Label());
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetViewLabelsForShape
|
||||
//purpose :
|
||||
@ -448,6 +512,25 @@ Standard_Boolean XCAFDoc_ViewTool::GetViewLabelsForClippingPlane(const TDF_Label
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :GetViewLabelsForEnabledShapesLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean XCAFDoc_ViewTool::GetViewLabelsForEnabledShapesLabel(const TDF_Label& theShapesTransparencyL,
|
||||
TDF_LabelSequence& theViews) const
|
||||
{
|
||||
Handle(XCAFDoc_GraphNode) aGNode;
|
||||
Standard_Boolean aResult = Standard_False;
|
||||
if (theShapesTransparencyL.FindAttribute(XCAFDoc::ViewRefPlaneGUID(), aGNode) && aGNode->NbChildren() > 0) {
|
||||
for (Standard_Integer i = 1; i <= aGNode->NbChildren(); i++)
|
||||
{
|
||||
theViews.Append(aGNode->GetChild(i)->Label());
|
||||
}
|
||||
aResult = Standard_True;
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsLocked
|
||||
//purpose :
|
||||
|
@ -78,9 +78,10 @@ public:
|
||||
//! Set Clipping planes to given View
|
||||
Standard_EXPORT void SetClippingPlanes(const TDF_LabelSequence& theClippingPlaneLabels,
|
||||
const TDF_Label& theViewL) const;
|
||||
|
||||
Standard_EXPORT void SetEnabledShapes(const TDF_LabelSequence& theShapesTransparencyLabels,
|
||||
const TDF_Label& theViewL) const;
|
||||
//! Returns all View labels defined for label ShapeL
|
||||
Standard_EXPORT Standard_Boolean GetViewLabelsForShape (const TDF_Label& theShapeL, TDF_LabelSequence& theViews) const;
|
||||
Standard_EXPORT Standard_Boolean GetViewLabelsForShape(const TDF_Label& theShapeL, TDF_LabelSequence& theViews) const;
|
||||
|
||||
//! Returns all View labels defined for label GDTL
|
||||
Standard_EXPORT Standard_Boolean GetViewLabelsForGDT (const TDF_Label& theGDTL, TDF_LabelSequence& theViews) const;
|
||||
@ -88,6 +89,9 @@ public:
|
||||
//! Returns all View labels defined for label ClippingPlaneL
|
||||
Standard_EXPORT Standard_Boolean GetViewLabelsForClippingPlane(const TDF_Label& theClippingPlaneL, TDF_LabelSequence& theViews) const;
|
||||
|
||||
//! Returns all View labels defined for label Shapes transparency
|
||||
Standard_EXPORT Standard_Boolean GetViewLabelsForEnabledShapesLabel(const TDF_Label& theShapesTransparencyL, TDF_LabelSequence& theViews) const;
|
||||
|
||||
//! Adds a view definition to a View table and returns its label
|
||||
Standard_EXPORT TDF_Label AddView() ;
|
||||
|
||||
@ -103,6 +107,9 @@ public:
|
||||
//! Returns False if the theViewL is not in View table
|
||||
Standard_EXPORT Standard_Boolean GetRefClippingPlaneLabel(const TDF_Label& theViewL, TDF_LabelSequence& theClippingPlaneLabels) const;
|
||||
|
||||
//! Returns shapes transparency labels defined for label theViewL
|
||||
//! Returns False if the theViewL is not in View table
|
||||
Standard_EXPORT Standard_Boolean GetRefEnabledShapesLabel(const TDF_Label& theViewL, TDF_LabelSequence& theShapesTranspanencyLabels) const;
|
||||
//! Returns true if the given View is marked as locked
|
||||
Standard_EXPORT Standard_Boolean IsLocked(const TDF_Label& theViewL) const;
|
||||
|
||||
|
@ -29,6 +29,7 @@ XCAFView_Object::XCAFView_Object()
|
||||
myViewVolumeSidesClipping = Standard_False;
|
||||
myGDTPoints = NULL;
|
||||
myImage = NULL;
|
||||
myEnabledShapes = NULL;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -52,5 +53,6 @@ XCAFView_Object::XCAFView_Object(const Handle(XCAFView_Object)& theObj)
|
||||
myViewVolumeSidesClipping = theObj->myViewVolumeSidesClipping;
|
||||
myGDTPoints = NULL;
|
||||
myImage = theObj->myImage;
|
||||
myEnabledShapes = NULL;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
#include <XCAFView_ProjectionType.hxx>
|
||||
#include <TColStd_HArray1OfByte.hxx>
|
||||
#include <TColStd_HArray1OfBoolean.hxx>
|
||||
|
||||
class XCAFView_Object;
|
||||
DEFINE_STANDARD_HANDLE(XCAFView_Object, Standard_Transient)
|
||||
@ -233,6 +234,43 @@ public:
|
||||
{
|
||||
return (!myImage.IsNull());
|
||||
}
|
||||
|
||||
Standard_EXPORT void CreateEnabledShapes(const Standard_Integer theLenght)
|
||||
{
|
||||
if (theLenght > 0)
|
||||
myEnabledShapes = new TColStd_HArray1OfBoolean(1, theLenght);
|
||||
}
|
||||
|
||||
Standard_EXPORT Standard_Boolean HasEnabledShapes()
|
||||
{
|
||||
return (!myEnabledShapes.IsNull());
|
||||
}
|
||||
|
||||
Standard_EXPORT Standard_Integer NbEnabledShapes()
|
||||
{
|
||||
if (myEnabledShapes.IsNull())
|
||||
return 0;
|
||||
return myEnabledShapes->Length();
|
||||
}
|
||||
|
||||
Standard_EXPORT void SetEnabledShape(const Standard_Integer theIndex, const bool theVal)
|
||||
{
|
||||
if (myEnabledShapes.IsNull())
|
||||
return;
|
||||
if (theIndex > 0 && theIndex <= myEnabledShapes->Length())
|
||||
myEnabledShapes->SetValue(theIndex, theVal);
|
||||
}
|
||||
|
||||
Standard_EXPORT bool EnabledShape(const Standard_Integer theIndex)
|
||||
{
|
||||
if (myEnabledShapes.IsNull())
|
||||
return Standard_False;
|
||||
if (theIndex > 0 && theIndex <= myEnabledShapes->Length())
|
||||
return myEnabledShapes->Value(theIndex);
|
||||
else
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(XCAFView_Object,Standard_Transient)
|
||||
|
||||
private:
|
||||
@ -253,6 +291,7 @@ private:
|
||||
Standard_Boolean myViewVolumeSidesClipping;
|
||||
Handle(TColgp_HArray1OfPnt) myGDTPoints; // Point for each GDT to describe position of GDT frame in View.
|
||||
Handle(TColStd_HArray1OfByte) myImage;
|
||||
Handle(TColStd_HArray1OfBoolean) myEnabledShapes;
|
||||
};
|
||||
|
||||
#endif // _XCAFView_Object_HeaderFile
|
||||
|
Loading…
x
Reference in New Issue
Block a user