mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
Storage the parts transparency in the view
This commit is contained in:
parent
49c79be2c3
commit
ea712b6b04
@ -250,6 +250,17 @@ Standard_GUID XCAFDoc::ViewRefPlaneGUID()
|
||||
return ID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ViewRefEnabledShapesGUID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_GUID XCAFDoc::ViewRefEnabledShapesGUID()
|
||||
{
|
||||
static Standard_GUID ID("efd213e4-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return ID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ViewRefPlaneGUID
|
||||
//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();
|
||||
|
||||
//! Return GUIDs for GraphNode representing specified types of View
|
||||
Standard_EXPORT static Standard_GUID ViewRefNoteGUID();
|
||||
|
@ -47,7 +47,8 @@ enum ChildLab
|
||||
ChildLab_ViewVolumeSidesClipping,
|
||||
ChildLab_ClippingExpression,
|
||||
ChildLab_GDTPoints,
|
||||
ChildLab_Image
|
||||
ChildLab_Image,
|
||||
ChildLab_EnabledShapes
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
@ -160,6 +161,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -275,6 +285,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;
|
||||
}
|
||||
|
||||
|
@ -447,6 +447,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 : RemoveView
|
||||
@ -561,6 +601,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 : GetRefNoteLabel
|
||||
//purpose :
|
||||
@ -666,6 +730,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 : GetViewLabelsForNote
|
||||
//purpose :
|
||||
|
@ -87,6 +87,9 @@ public:
|
||||
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;
|
||||
|
||||
//! Remove View
|
||||
Standard_EXPORT void RemoveView(const TDF_Label& theViewL);
|
||||
|
||||
@ -105,6 +108,9 @@ public:
|
||||
//! Returns all View labels defined for label AnnotationL
|
||||
Standard_EXPORT Standard_Boolean GetViewLabelsForAnnotation(const TDF_Label& theAnnotationL, 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() ;
|
||||
|
||||
@ -120,6 +126,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 Notes labels defined for label theViewL
|
||||
//! Returns False if the theViewL is not in View table
|
||||
Standard_EXPORT Standard_Boolean GetRefNoteLabel(const TDF_Label& theViewL, TDF_LabelSequence& theNoteLabels) 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