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

Compare commits

...

8 Commits

Author SHA1 Message Date
nds
a4b39dfd78 #265 Possibility to display materials by different hatching style when we make clipping
Conflicts:
	src/Graphic3d/Graphic3d_ClipPlane.cxx
	src/Graphic3d/Graphic3d_ClipPlane.hxx
	src/OpenGl/OpenGl_CappingAlgo.cxx
	src/OpenGl/OpenGl_CappingAlgo.hxx
	src/OpenGl/OpenGl_CappingPlaneResource.cxx
	src/OpenGl/OpenGl_Element.hxx
	src/OpenGl/OpenGl_Workspace.cxx
	src/ViewerTest/ViewerTest_ViewerCommands.cxx
2018-09-27 16:35:37 +03:00
nds
983e8b5d2e Corrections after rebasing on IR 2018-09-06 17:00:07 +03:00
nds
c415a8ed4d 0028954: Visualization - implement interactive object for camera manipulations - corrected view cube positioning
Conflicts:
	src/AIS/AIS_ViewCube.cxx
	tests/v3d/viewcube/style
2018-09-05 16:39:30 +03:00
nds
963eb43575 refs 474:Possibility to create and play animations 2018-09-05 16:25:49 +03:00
nds
5311a9d335 refs #355: Add possibility to hide clipping plane 2018-09-05 16:22:53 +03:00
nds
d912a14c29 Fix reading name of shape from subtype of PRODUCT_DEFINITION STEP entity 2018-09-05 16:21:15 +03:00
nds
5043017379 XCAFDoc/View fixes to store in the view: image, parts transparency, notes, notes positions 2018-09-05 16:19:37 +03:00
nds
8ef7bf92d1 0028954: Visualization - implement interactive object for camera manipulations
Conflicts:
	src/ViewerTest/ViewerTest_ViewerCommands.cxx
2018-09-05 16:06:05 +03:00
68 changed files with 7083 additions and 570 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -632,6 +632,9 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation
{
aShadedGroup = Prs3d_Root::NewGroup (thePrs);
aShadedGroup->SetClosed (isClosed);
if (isClosed
&& !myCappingStyle.IsNull())
aShadedGroup->SetGroupPrimitivesAspect (myCappingStyle);
}
aShadedGroup->SetPrimitivesAspect (aDrawer->ShadingAspect()->Aspect());
aShadedGroup->AddPrimitiveArray (aTriangles);

View File

@@ -21,6 +21,7 @@
#include <Aspect_PolygonOffsetMode.hxx>
#include <Bnd_Box.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectFillCapping.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
@@ -277,6 +278,37 @@ void AIS_InteractiveObject::UnsetMaterial()
hasOwnMaterial = Standard_False;
}
//=======================================================================
//function : SetCappingStyle
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetCappingStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle)
{
myCappingStyle = theStyle;
// Modify existing presentations
for (Standard_Integer aPrsIter = 1, n = myPresentations.Length(); aPrsIter <= n; ++aPrsIter)
{
const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation();
if (!aPrs3d.IsNull())
{
const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation();
if (!aStruct.IsNull())
{
const Graphic3d_SequenceOfGroup& aGroups = aStruct->Groups();
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next())
{
Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue();
if (aGrp.IsNull())
continue;
aGrp->SetGroupPrimitivesAspect (theStyle);
}
}
}
}
}
//=======================================================================
//function : SetTransparency
//purpose :
@@ -623,6 +655,7 @@ void AIS_InteractiveObject::SynchronizeAspects()
Handle(Graphic3d_AspectLine3d) aLineAspect = aGrp->LineAspect();
Handle(Graphic3d_AspectFillArea3d) aFaceAspect = aGrp->FillAreaAspect();
Handle(Graphic3d_AspectFillCapping) aCappingAspect = aGrp->FillCappingAspect();
Handle(Graphic3d_AspectMarker3d) aMarkerAspect = aGrp->MarkerAspect();
Handle(Graphic3d_AspectText3d) aTextAspect = aGrp->TextAspect();
if (!aLineAspect.IsNull())
@@ -633,6 +666,10 @@ void AIS_InteractiveObject::SynchronizeAspects()
{
aGrp->SetGroupPrimitivesAspect (aFaceAspect);
}
if (!aCappingAspect.IsNull())
{
aGrp->SetGroupPrimitivesAspect (aCappingAspect);
}
if (!aMarkerAspect.IsNull())
{
aGrp->SetGroupPrimitivesAspect (aMarkerAspect);

View File

@@ -310,6 +310,12 @@ public:
//! Removes the setting for material.
Standard_EXPORT virtual void UnsetMaterial();
//! Set style of filling capping section created by clipping planes.
Standard_EXPORT virtual void SetCappingStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle);
//! Returns style for filling capping section created by clipping planes.
const Handle(Graphic3d_AspectFillCapping)& CappingStyle() const { return myCappingStyle; }
//! Attributes a setting aValue for transparency.
//! The transparency value should be between 0.0 and 1.0.
//! At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
@@ -416,6 +422,7 @@ protected:
Standard_Boolean hasOwnColor;
Standard_Boolean hasOwnMaterial;
Standard_Boolean myRecomputeEveryPrs;
Handle(Graphic3d_AspectFillCapping) myCappingStyle;
};

View File

@@ -156,10 +156,7 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
try
{
OCC_CATCH_SIGNALS
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer,
myDrawer->ShadingAspect()->Aspect()->ToMapTexture()
&& !myDrawer->ShadingAspect()->Aspect()->TextureMap().IsNull(),
myUVOrigin, myUVRepeat, myUVScale);
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer, myCappingStyle);
}
catch (Standard_Failure const& anException)
{

2077
src/AIS/AIS_ViewCube.cxx Normal file

File diff suppressed because it is too large Load Diff

1050
src/AIS/AIS_ViewCube.hxx Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -172,3 +172,5 @@ AIS_TypeOfAxis.hxx
AIS_TypeOfDist.hxx
AIS_TypeOfIso.hxx
AIS_TypeOfPlane.hxx
AIS_ViewCube.hxx
AIS_ViewCube.cxx

View File

@@ -42,6 +42,9 @@ class BinMXCAFDoc_DimTolToolDriver;
class BinMXCAFDoc_MaterialToolDriver;
class BinMXCAFDoc_ViewDriver;
class BinMXCAFDoc_ViewToolDriver;
class BinMXCAFDoc_AnimationDriver;
class BinMXCAFDoc_AnimationToolDriver;
@@ -89,6 +92,9 @@ friend class BinMXCAFDoc_DimTolToolDriver;
friend class BinMXCAFDoc_MaterialToolDriver;
friend class BinMXCAFDoc_ViewDriver;
friend class BinMXCAFDoc_ViewToolDriver;
friend class BinMXCAFDoc_AnimationDriver;
friend class BinMXCAFDoc_AnimationToolDriver;
};

View File

@@ -0,0 +1,112 @@
// Created on: 2017-10-02
// Created by: Elena MOZOKHINA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BinMXCAFDoc_AnimationDriver.hxx>
#include <BinObjMgt_Persistent.hxx>
#include <Message_Messenger.hxx>
#include <Standard_Type.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TDF_Attribute.hxx>
#include <XCAFDoc_Animation.hxx>
# include <TColStd_HArray1OfByte.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_AnimationDriver,BinMDF_ADriver)
static Standard_Boolean getByteArray(const BinObjMgt_Persistent& theSource, Handle(TColStd_HArray1OfByte)& theArray)
{
Standard_Integer aFirstInd, aLastInd;
if (!(theSource >> aFirstInd >> aLastInd))
return Standard_False;
if (aLastInd < aFirstInd)
return Standard_False;
theArray.reset(new TColStd_HArray1OfByte(aFirstInd, aLastInd - aFirstInd + 1));
theSource.GetByteArray(&theArray->ChangeFirst(), aLastInd - aFirstInd + 1);
return Standard_True;
}
static void putByteArray(BinObjMgt_Persistent& theTarget, const Handle(TColStd_HArray1OfByte)& theArray)
{
if (theArray.IsNull())
return;
const Standard_Integer aFirstInd = theArray->Lower();
const Standard_Integer aLastInd = theArray->Upper();
if (aLastInd < aFirstInd)
return;
theTarget << aFirstInd << aLastInd;
theTarget.PutByteArray(&theArray->ChangeFirst(), aLastInd - aFirstInd + 1);
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
BinMXCAFDoc_AnimationDriver::BinMXCAFDoc_AnimationDriver
(const Handle(Message_Messenger)& theMsgDriver)
: BinMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_Animation)->Name())
{
}
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) BinMXCAFDoc_AnimationDriver::NewEmpty() const
{
return new XCAFDoc_Animation();
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
Standard_Boolean BinMXCAFDoc_AnimationDriver::Paste(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& /*theRelocTable*/) const
{
Handle(XCAFDoc_Animation) anAtt = Handle(XCAFDoc_Animation)::DownCast(theTarget);
Standard_Real aDensity;
TCollection_AsciiString aName;
if (!(theSource >> aName))
return Standard_False;
Handle(TColStd_HArray1OfByte) anImage, anAnimation;
if (!getByteArray(theSource, anImage) || anImage.IsNull())
return Standard_False;
if (!getByteArray(theSource, anAnimation) || anAnimation.IsNull())
return Standard_False;
anAtt->Set(new TCollection_HAsciiString(aName), anImage, anAnimation);
return Standard_True;
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void BinMXCAFDoc_AnimationDriver::Paste(const Handle(TDF_Attribute)& theSource,
BinObjMgt_Persistent& theTarget,
BinObjMgt_SRelocationTable& /*theRelocTable*/) const
{
Handle(XCAFDoc_Animation) anAtt = Handle(XCAFDoc_Animation)::DownCast(theSource);
Handle(TCollection_HAsciiString) aName = anAtt->GetName();
if (!aName.IsNull())
theTarget << aName->String();
putByteArray(theTarget, anAtt->GetImage());
putByteArray(theTarget, anAtt->GetAnimation());
}

View File

@@ -0,0 +1,72 @@
// Created on: 2017-10-02
// Created by: Elena MOZOKHINA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BinMXCAFDoc_AnimationDriver_HeaderFile
#define _BinMXCAFDoc_AnimationDriver_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <BinMDF_ADriver.hxx>
#include <Standard_Boolean.hxx>
#include <BinObjMgt_RRelocationTable.hxx>
#include <BinObjMgt_SRelocationTable.hxx>
class Message_Messenger;
class TDF_Attribute;
class BinObjMgt_Persistent;
class BinMXCAFDoc_AnimationDriver;
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_AnimationDriver, BinMDF_ADriver)
class BinMXCAFDoc_AnimationDriver : public BinMDF_ADriver
{
public:
Standard_EXPORT BinMXCAFDoc_AnimationDriver(const Handle(Message_Messenger)& theMsgDriver);
Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Paste (const BinObjMgt_Persistent& theSource, const Handle(TDF_Attribute)& theTarget, BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& theSource, BinObjMgt_Persistent& theTarget, BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_AnimationDriver,BinMDF_ADriver)
protected:
private:
};
#endif // _BinMXCAFDoc_AnimationDriver_HeaderFile

View File

@@ -0,0 +1,65 @@
// Created on: 2017-10-02
// Created by: Elena MOZOKHINA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BinMXCAFDoc_AnimationToolDriver.hxx>
#include <BinObjMgt_Persistent.hxx>
#include <Message_Messenger.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <XCAFDoc_AnimationTool.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_AnimationToolDriver, BinMDF_ADriver)
//=======================================================================
//function :
//purpose :
//=======================================================================
BinMXCAFDoc_AnimationToolDriver::BinMXCAFDoc_AnimationToolDriver
(const Handle(Message_Messenger)& theMsgDriver)
: BinMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_AnimationTool)->Name())
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(TDF_Attribute) BinMXCAFDoc_AnimationToolDriver::NewEmpty() const
{
return new XCAFDoc_AnimationTool();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean BinMXCAFDoc_AnimationToolDriver::Paste
(const BinObjMgt_Persistent& /*theSource*/,
const Handle(TDF_Attribute)& /*theTarget*/,
BinObjMgt_RRelocationTable& /*theRelocTable*/) const
{
return Standard_True;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void BinMXCAFDoc_AnimationToolDriver::Paste
(const Handle(TDF_Attribute)& /*theSource*/,
BinObjMgt_Persistent& /*theTarget*/,
BinObjMgt_SRelocationTable& /*theRelocTable*/) const {
}

View File

@@ -0,0 +1,50 @@
// Created on: 2017-10-02
// Created by: Elena MOZOKHINA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BinMXCAFDoc_AnimationToolDriver_HeaderFile
#define _BinMXCAFDoc_AnimationToolDriver_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <BinMDF_ADriver.hxx>
#include <Standard_Boolean.hxx>
#include <BinObjMgt_RRelocationTable.hxx>
#include <BinObjMgt_SRelocationTable.hxx>
class Message_Messenger;
class TDF_Attribute;
class BinObjMgt_Persistent;
class BinMXCAFDoc_AnimationToolDriver;
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_AnimationToolDriver, BinMDF_ADriver)
class BinMXCAFDoc_AnimationToolDriver : public BinMDF_ADriver
{
public:
Standard_EXPORT BinMXCAFDoc_AnimationToolDriver(const Handle(Message_Messenger)& theMsgDriver);
Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Paste(const BinObjMgt_Persistent& theSource, const Handle(TDF_Attribute)& theTarget, BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
Standard_EXPORT virtual void Paste(const Handle(TDF_Attribute)& theSource, BinObjMgt_Persistent& theTarget, BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_AnimationToolDriver, BinMDF_ADriver)
};
#endif // _BinMXCAFDoc_AnimationToolDriver_HeaderFile

View File

@@ -53,3 +53,7 @@ BinMXCAFDoc_ViewToolDriver.cxx
BinMXCAFDoc_ViewToolDriver.hxx
BinMXCAFDoc_VolumeDriver.cxx
BinMXCAFDoc_VolumeDriver.hxx
BinMXCAFDoc_AnimationDriver.cxx
BinMXCAFDoc_AnimationDriver.hxx
BinMXCAFDoc_AnimationToolDriver.cxx
BinMXCAFDoc_AnimationToolDriver.hxx

View File

@@ -12,6 +12,8 @@ Graphic3d_ArrayOfTriangles.hxx
Graphic3d_ArrayOfTriangleStrips.hxx
Graphic3d_AspectFillArea3d.cxx
Graphic3d_AspectFillArea3d.hxx
Graphic3d_AspectFillCapping.cxx
Graphic3d_AspectFillCapping.hxx
Graphic3d_AspectLine3d.cxx
Graphic3d_AspectLine3d.hxx
Graphic3d_AspectMarker3d.cxx

View File

@@ -0,0 +1,110 @@
// Created on: 2017-04-14
// Created by: Anton POLETAEV
// Copyright (c) 2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Graphic3d_AspectFillCapping.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectFillCapping, Standard_Transient)
// =======================================================================
// function : Graphic3d_AspectFillCapping
// purpose :
// =======================================================================
Graphic3d_AspectFillCapping::Graphic3d_AspectFillCapping()
: myFlags (Flags_None),
myHatchingState (0)
{
Graphic3d_MaterialAspect aMaterial;
aMaterial.SetColor (Quantity_NOC_BLACK);
aMaterial.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
aMaterial.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
aMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
aMaterial.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
aMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
SetHatchStyle (Aspect_HS_HORIZONTAL);
SetHatchMaterial (aMaterial);
}
// =======================================================================
// function : SetHatchStyle
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchStyle (const Aspect_HatchStyle theStyle)
{
myStippleHatch = new Graphic3d_HatchStyle (theStyle);
myTextureHatch.Nullify();
myHatchingState++;
}
// =======================================================================
// function : SetHatchStyle
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle)
{
myStippleHatch = theStyle;
myTextureHatch.Nullify();
myHatchingState++;
}
// =======================================================================
// function : SetHatchStyle
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchStyle (const Handle(Graphic3d_TextureMap)& theTexture)
{
myStippleHatch.Nullify();
myTextureHatch = theTexture;
myHatchingState++;
}
// =======================================================================
// function : SetHatchMaterial
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchMaterial (const Graphic3d_MaterialAspect& theMaterial)
{
myHatchMaterial = theMaterial;
myHatchingState++;
}
// =======================================================================
// function : SetToDrawHatch
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetToDrawHatch (const Standard_Boolean theToDraw)
{
setFlag (theToDraw, Flags_DrawHatching);
myHatchingState++;
}
// =======================================================================
// function : SetHatchZoomPeristent
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchZoomPeristent (const Standard_Boolean theToSet)
{
setFlag (theToSet, Flags_HatchZoomPersistent);
myHatchingState++;
}
// =======================================================================
// function : SetHatchRotationPeristent
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchRotationPeristent (const Standard_Boolean theToSet)
{
setFlag (theToSet, Flags_HatchRotationPersistent);
myHatchingState++;
}

View File

@@ -0,0 +1,163 @@
// Created on: 2017-04-14
// Created by: Anton POLETAEV
// Copyright (c) 2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Graphic3d_AspectFillCapping_HeaderFile
#define _Graphic3d_AspectFillCapping_HeaderFile
#include <Aspect_HatchStyle.hxx>
#include <Graphic3d_HatchStyle.hxx>
#include <Graphic3d_MaterialAspect.hxx>
#include <Graphic3d_ShaderProgram.hxx>
#include <Graphic3d_TextureMap.hxx>
#include <Standard_Transient.hxx>
//! Defines graphical attributes for drawing section planes on solids resulted from clipping (cutting) planes.
class Graphic3d_AspectFillCapping : public Standard_Transient
{
public:
//! Default constructor.
Standard_EXPORT Graphic3d_AspectFillCapping();
public:
//! Sets material for filling section created by clipping.
void SetMaterial (const Graphic3d_MaterialAspect& theMaterial) { myMaterial = theMaterial; }
//! Returns material for filling section created by clipping.
const Graphic3d_MaterialAspect& Material() const { return myMaterial; }
//! Sets flag indicating whether object's material (instead of defined by this aspect) should be used for filling section.
void SetUseObjectMaterial (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectMaterial); }
//! Returns flag indicating whether object's material (instead of defined by this aspect) should be used for filling section.
Standard_Boolean ToUseObjectMaterial() const { return (myFlags & Flags_UseObjectMaterial) != 0; }
//! Sets texture for filling section created by clipping.
void SetTexture (const Handle(Graphic3d_TextureMap)& theTexture) { myTexture = theTexture; }
//! Returns texture for filling section created by clipping.
const Handle(Graphic3d_TextureMap)& Texture() const { return myTexture; }
//! Sets flag indicating whether object's texture (instead of defined by this aspect) should be used for filling section.
void SetUseObjectTexture (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectTexture); }
//! Returns flag indicating whether object's texture (instead of defined by this aspect) should be used for filling section.
Standard_Boolean ToUseObjectTexture() const { return (myFlags & Flags_UseObjectTexture) != 0; }
//! Sets OpenGL/GLSL shader program.
void SetShader (const Handle(Graphic3d_ShaderProgram)& theShader) { myShader = theShader; }
//! Returns OpenGL/GLSL shader program.
const Handle(Graphic3d_ShaderProgram)& Shader() const { return myShader; }
//! Sets flag indicating whether object's shader (instead of defined by this aspect) should be used for filling section.
void SetUseObjectShader (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectShader); }
//! Returns flag indicating whether object's shader (instead of defined by this aspect) should be used for filling section.
Standard_Boolean ToUseObjectShader() const { return (myFlags & Flags_UseObjectShader) != 0; }
public:
//! Sets style of hatch defined by predefined stipple mask.
Standard_EXPORT void SetHatchStyle (const Aspect_HatchStyle theStyle);
//! Sets style of hatch defined by custom stipple mask.
Standard_EXPORT void SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle);
//! Sets style of hatch defined by texture map (decal texture with alpha channel should be used).
Standard_EXPORT void SetHatchStyle (const Handle(Graphic3d_TextureMap)& theTexture);
//! Sets material style for hatch lines (texture).
Standard_EXPORT void SetHatchMaterial (const Graphic3d_MaterialAspect& theMaterial);
//! Returns material style for hatch lines (texture).
const Graphic3d_MaterialAspect& HatchMaterial() const { return myHatchMaterial; }
//! Sets boolean flag indicating whether the hatch layer should be drawn or not.
Standard_EXPORT void SetToDrawHatch (const Standard_Boolean theToDraw);
//! Returns boolean flag indicating whether the hatch layer should be drawn or not.
Standard_Boolean ToDrawHatch() const { return (myFlags & Flags_DrawHatching) != 0; }
//! Sets flag controlling behavior of hatch texture mapping on zooming.
//! @param theToSet [in] if passed TRUE the texture will keep constant screen-scale independent of zooming.
Standard_EXPORT void SetHatchZoomPeristent (const Standard_Boolean theToSet);
//! Returns value of flag controlling behavior of hatch texture mapping on zooming.
Standard_Boolean IsHatchZoomPersistent() { return (myFlags & Flags_HatchZoomPersistent) != 0; }
//! Sets flag controlling behavior of hatch texture mapping on camera rotation around heading vector.
Standard_EXPORT void SetHatchRotationPeristent (const Standard_Boolean theToSet);
//! Returns value of flag controlling behavior of hatch texture mapping on camera rotation around heading vector.
Standard_Boolean IsHatchRotationPersistent() { return (myFlags & Flags_HatchRotationPersistent) != 0; }
//! Returns true if hatch is defined by texture.
Standard_Boolean IsTextureHatch() const { return !myTextureHatch.IsNull(); }
//! Returns texture map defining the hatch.
const Handle(Graphic3d_TextureMap)& TextureHatch() const { return myTextureHatch; }
//! Returns true if hatch is defined by stipple mask.
Standard_Boolean IsStippleHatch() const { return !myStippleHatch.IsNull(); }
//! Returns the stipple mask.
const Handle(Graphic3d_HatchStyle)& StippleHatch() const { return myStippleHatch; }
//! Returns modification counter for hatching state.
Standard_Size HatchingState() const { return myHatchingState; }
private:
enum Flags
{
Flags_None = 0x00, //!< no flags
Flags_UseObjectMaterial = 0x01, //!< use object material
Flags_UseObjectTexture = 0x02, //!< use object texture
Flags_UseObjectShader = 0x04, //!< use object GLSL program
Flags_HatchZoomPersistent = 0x08, //!< zoom-persistent texturing
Flags_HatchRotationPersistent = 0x10, //!< rotation-persistent texturing
Flags_DrawHatching = 0x20, //!< draw hatching
Flags_UseObjectProperties = //!< use entire fill area aspect from object
Flags_UseObjectMaterial
| Flags_UseObjectTexture
| Flags_UseObjectShader
};
void setFlag (const Standard_Boolean theToUse, const unsigned int theFlag)
{
myFlags = theToUse ? myFlags | theFlag : myFlags & ~theFlag;
}
private:
Graphic3d_MaterialAspect myMaterial;
Handle(Graphic3d_TextureMap) myTexture;
Handle(Graphic3d_ShaderProgram) myShader;
Handle(Graphic3d_HatchStyle) myStippleHatch;
Handle(Graphic3d_TextureMap) myTextureHatch;
Graphic3d_MaterialAspect myHatchMaterial;
unsigned int myFlags;
Standard_Size myHatchingState;
public:
DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectFillCapping, Standard_Transient)
};
DEFINE_STANDARD_HANDLE (Graphic3d_AspectFillCapping, Standard_Transient)
#endif // _Graphic3d_AspectFillCapping_HeaderFile

View File

@@ -24,19 +24,6 @@ IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ClipPlane,Standard_Transient)
namespace
{
static volatile Standard_Integer THE_CLIP_PLANE_COUNTER = 0;
static Handle(Graphic3d_AspectFillArea3d) defaultAspect()
{
const Graphic3d_MaterialAspect aMaterial (Graphic3d_NOM_DEFAULT);
Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
anAspect->SetDistinguishOff();
anAspect->SetFrontMaterial (aMaterial);
anAspect->SetHatchStyle (Aspect_HS_HORIZONTAL);
anAspect->SetInteriorStyle (Aspect_IS_SOLID);
anAspect->SetInteriorColor (aMaterial.Color());
anAspect->SetSuppressBackFaces (false);
return anAspect;
}
}
// =======================================================================
@@ -44,19 +31,8 @@ namespace
// purpose :
// =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane()
: myAspect (defaultAspect()),
myPrevInChain(NULL),
myPlane (0.0, 0.0, 1.0, 0.0),
myEquation (0.0, 0.0, 1.0, 0.0),
myEquationRev(0.0, 0.0,-1.0, 0.0),
myChainLenFwd(1),
myFlags (Graphic3d_CappingFlags_None),
myEquationMod(0),
myAspectMod (0),
myIsOn (Standard_True),
myIsCapping (Standard_False)
{
makeId();
init();
}
// =======================================================================
@@ -64,19 +40,8 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane()
// purpose :
// =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_Vec4d& theEquation)
: myAspect (defaultAspect()),
myPrevInChain(NULL),
myPlane (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w()),
myEquation (theEquation),
myEquationRev(0.0, 0.0,-1.0, 0.0),
myChainLenFwd(1),
myFlags (Graphic3d_CappingFlags_None),
myEquationMod(0),
myAspectMod (0),
myIsOn (Standard_True),
myIsCapping (Standard_False)
{
makeId();
init (gp_Pln (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.a()));
updateInversedPlane();
}
@@ -84,42 +49,27 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_Vec4d& theEquation)
// function : Graphic3d_ClipPlane
// purpose :
// =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
: Standard_Transient(theOther),
myAspect (defaultAspect()),
myPrevInChain(NULL),
myPlane (theOther.myPlane),
myEquation (theOther.myEquation),
myEquationRev(theOther.myEquationRev),
myChainLenFwd(1),
myFlags (theOther.myFlags),
myEquationMod(0),
myAspectMod (0),
myIsOn (theOther.myIsOn),
myIsCapping (theOther.myIsCapping)
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_ClipPlane& theOther)
: Standard_Transient (theOther)
{
makeId();
*myAspect = *theOther.CappingAspect();
*mySectionStyle = *theOther.CappingSectionStyle();
init (theOther.myPlane,
theOther.myEquationRev,
theOther.myIsOn,
theOther.myIsCapping,
theOther.ToOverrideCappingAspect(),
theOther.CappingSectionStyle());
updateInversedPlane();
}
// =======================================================================
// function : Graphic3d_ClipPlane
// purpose :
// =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
: myAspect (defaultAspect()),
myPrevInChain(NULL),
myPlane (thePlane),
myChainLenFwd(1),
myFlags (Graphic3d_CappingFlags_None),
myEquationMod(0),
myAspectMod (0),
myIsOn (Standard_True),
myIsCapping (Standard_False)
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const gp_Pln& thePlane)
{
thePlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
init (thePlane);
updateInversedPlane();
makeId();
}
// =======================================================================
@@ -131,7 +81,7 @@ void Graphic3d_ClipPlane::SetEquation (const Graphic3d_Vec4d& theEquation)
myPlane = gp_Pln (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w());
myEquation = theEquation;
updateInversedPlane();
myEquationMod++;
myOrientationDirty = Standard_True;
}
// =======================================================================
@@ -143,7 +93,7 @@ void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane)
myPlane = thePlane;
thePlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
updateInversedPlane();
myEquationMod++;
myOrientationDirty = Standard_True;
}
// =======================================================================
@@ -178,119 +128,106 @@ Handle(Graphic3d_ClipPlane) Graphic3d_ClipPlane::Clone() const
}
// =======================================================================
// function : SetCappingMaterial
// function : SetCappingSectionStyle
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& theMat)
void Graphic3d_ClipPlane::SetCappingSectionStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle)
{
myAspect->SetFrontMaterial (theMat);
myAspect->SetInteriorColor (theMat.Color());
++myAspectMod;
mySectionStyle = theStyle;
}
// =======================================================================
// function : SetCappingTexture
// function : OrientationMatrix
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture)
const Graphic3d_Mat4& Graphic3d_ClipPlane::OrientationMatrix() const
{
if (!theTexture.IsNull())
if (myOrientationDirty)
{
myAspect->SetTextureMapOn();
Handle(Graphic3d_TextureSet) aTextureSet = myAspect->TextureSet();
if (aTextureSet.IsNull() || aTextureSet->Size() != 1)
const Standard_ShortReal aDirection[] = {
static_cast<Standard_ShortReal> (myEquation[0]),
static_cast<Standard_ShortReal> (myEquation[1]),
static_cast<Standard_ShortReal> (myEquation[2])
};
const Standard_ShortReal aTranslate[] = {
static_cast<Standard_ShortReal> (myEquation[0] * -myEquation[3]),
static_cast<Standard_ShortReal> (myEquation[1] * -myEquation[3]),
static_cast<Standard_ShortReal> (myEquation[2] * -myEquation[3])
};
Standard_ShortReal aSide1[] = { 0.0f, 0.0f, 0.0f };
Standard_ShortReal aSide2[] = { 0.0f, 0.0f, 0.0f };
const Standard_ShortReal aMagintude = static_cast<Standard_ShortReal> (Sqrt (myEquation[0] * myEquation[0] + myEquation[2] * myEquation[2]));
if (aMagintude < ShortRealSmall())
{
aTextureSet = new Graphic3d_TextureSet (theTexture);
aSide1[0] = 1.0f;
}
else
{
aTextureSet->SetFirst (theTexture);
aSide1[0] = aDirection[2] / aMagintude;
aSide1[2] = -aDirection[0] / aMagintude;
}
myAspect->SetTextureSet (aTextureSet);
aSide2[0] = (-aSide1[1] * aDirection[2]) - (-aSide1[2] * aDirection[1]);
aSide2[1] = (-aSide1[2] * aDirection[0]) - (-aSide1[0] * aDirection[2]);
aSide2[2] = (-aSide1[0] * aDirection[1]) - (-aSide1[1] * aDirection[0]);
myOrientationMat.SetValue (0, 0, aSide1[0]);
myOrientationMat.SetValue (1, 0, aSide1[1]);
myOrientationMat.SetValue (2, 0, aSide1[2]);
myOrientationMat.SetValue (3, 0, 0.0F);
myOrientationMat.SetValue (0, 1, aDirection[0]);
myOrientationMat.SetValue (1, 1, aDirection[1]);
myOrientationMat.SetValue (2, 1, aDirection[2]);
myOrientationMat.SetValue (3, 1, 0.0F);
myOrientationMat.SetValue (0, 2, aSide2[0]);
myOrientationMat.SetValue (1, 2, aSide2[1]);
myOrientationMat.SetValue (2, 2, aSide2[2]);
myOrientationMat.SetValue (3, 2, 0.0F);
myOrientationMat.SetValue (0, 3, aTranslate[0]);
myOrientationMat.SetValue (1, 3, aTranslate[1]);
myOrientationMat.SetValue (2, 3, aTranslate[2]);
myOrientationMat.SetValue (3, 3, 1.0F);
myOrientationDirty = Standard_False;
}
else
return myOrientationMat;
}
// =======================================================================
// function : init
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::init (const gp_Pln& thePlane,
const Graphic3d_Vec4d& theEquationRev,
const Standard_Boolean theIsOn,
const Standard_Boolean theIsCapping,
const Standard_Boolean theOverrideStyle,
const Handle(Graphic3d_AspectFillCapping)& theStyle)
{
if (myEntityUID.IsEmpty())
{
myAspect->SetTextureMapOff();
myAspect->SetTextureSet (Handle(Graphic3d_TextureSet)());
myEntityUID = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
}
++myAspectMod;
}
// =======================================================================
// function : SetCappingHatch
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle)
{
myAspect->SetHatchStyle (theStyle);
++myAspectMod;
}
// =======================================================================
// function : SetCappingCustomHatch
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingCustomHatch (const Handle(Graphic3d_HatchStyle)& theStyle)
{
myAspect->SetHatchStyle (theStyle);
++myAspectMod;
}
// =======================================================================
// function : SetCappingHatchOn
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingHatchOn()
{
myAspect->SetInteriorStyle (Aspect_IS_HATCH);
++myAspectMod;
}
// =======================================================================
// function : SetCappingHatchOff
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingHatchOff()
{
myAspect->SetInteriorStyle (Aspect_IS_SOLID);
++myAspectMod;
}
// =======================================================================
// function : SetCappingAspect
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
{
myAspect = theAspect;
++myAspectMod;
}
// =======================================================================
// function : setCappingFlag
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::setCappingFlag (bool theToUse, int theFlag)
{
if (theToUse)
{
myFlags |= theFlag;
}
else
{
myFlags &= ~(theFlag);
}
++myAspectMod;
}
// =======================================================================
// function : makeId
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::makeId()
{
myId = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
myPrevInChain = NULL;
myEquationRev = theEquationRev;
myChainLenFwd = 1;
myPlane = thePlane;
myPlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
myIsOn = theIsOn;
myIsCapping = theIsCapping;
myOverrideObjectStyle = theOverrideStyle;
mySectionStyle = theStyle.IsNull() ? new Graphic3d_AspectFillCapping() : theStyle;
myOrientationDirty = Standard_True;
}
// =======================================================================
@@ -312,7 +249,7 @@ void Graphic3d_ClipPlane::updateChainLen()
// =======================================================================
void Graphic3d_ClipPlane::SetChainNextPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
{
++myEquationMod;
myOrientationDirty = Standard_True;
if (!myNextInChain.IsNull())
{
myNextInChain->myPrevInChain = NULL;

View File

@@ -19,9 +19,12 @@
#include <Aspect_HatchStyle.hxx>
#include <gp_Pln.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectFillCapping.hxx>
#include <Graphic3d_BndBox3d.hxx>
#include <Graphic3d_CappingFlags.hxx>
#include <Graphic3d_Mat4.hxx>
#include <Graphic3d_TextureMap.hxx>
#include <NCollection_Handle.hxx>
#include <NCollection_Vec4.hxx>
#include <Standard_Macro.hxx>
#include <Standard_TypeDef.hxx>
@@ -166,44 +169,6 @@ public:
public: // @name user-defined graphical attributes
//! Set material for rendering capping surface.
//! @param theMat [in] the material.
Standard_EXPORT void SetCappingMaterial (const Graphic3d_MaterialAspect& theMat);
//! @return capping material.
const Graphic3d_MaterialAspect& CappingMaterial() const { return myAspect->FrontMaterial(); }
//! Set texture to be applied on capping surface.
//! @param theTexture [in] the texture.
Standard_EXPORT void SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture);
//! @return capping texture map.
Handle(Graphic3d_TextureMap) CappingTexture() const { return !myAspect->TextureSet().IsNull() && !myAspect->TextureSet()->IsEmpty()
? myAspect->TextureSet()->First()
: Handle(Graphic3d_TextureMap)(); }
//! Set hatch style (stipple) and turn hatching on.
//! @param theStyle [in] the hatch style.
Standard_EXPORT void SetCappingHatch (const Aspect_HatchStyle theStyle);
//! @return hatching style.
Aspect_HatchStyle CappingHatch() const { return (Aspect_HatchStyle)myAspect->HatchStyle()->HatchType(); }
//! Set custom hatch style (stipple) and turn hatching on.
//! @param theStyle [in] the hatch pattern.
Standard_EXPORT void SetCappingCustomHatch (const Handle(Graphic3d_HatchStyle)& theStyle);
//! @return hatching style.
const Handle(Graphic3d_HatchStyle)& CappingCustomHatch() const { return myAspect->HatchStyle(); }
//! Turn on hatching.
Standard_EXPORT void SetCappingHatchOn();
//! Turn off hatching.
Standard_EXPORT void SetCappingHatchOff();
//! @return True if hatching mask is turned on.
Standard_Boolean IsHatchOn() const { return myAspect->InteriorStyle() == Aspect_IS_HATCH; }
//! This ID is used for managing associated resources in graphical driver.
//! The clip plane can be assigned within a range of IO which can be
@@ -214,41 +179,18 @@ public: // @name user-defined graphical attributes
//! @return clip plane resource identifier string.
const TCollection_AsciiString& GetId() const
{
return myId;
return myEntityUID;
}
public:
//! Return capping aspect.
//! Returns style used for drawing capping section.
//! @return capping surface rendering aspect.
const Handle(Graphic3d_AspectFillArea3d)& CappingAspect() const { return myAspect; }
const Handle(Graphic3d_AspectFillCapping)& CappingSectionStyle() const { return mySectionStyle; }
//! Assign capping aspect.
Standard_EXPORT void SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect);
//! Sets clipping section filling aspect.
Standard_EXPORT void SetCappingSectionStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle);
//! Flag indicating whether material for capping plane should be taken from object.
//! Default value: FALSE (use dedicated capping plane material).
bool ToUseObjectMaterial() const { return (myFlags & Graphic3d_CappingFlags_ObjectMaterial) != 0; }
//! Set flag for controlling the source of capping plane material.
void SetUseObjectMaterial (bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectMaterial); }
//! Flag indicating whether texture for capping plane should be taken from object.
//! Default value: FALSE.
bool ToUseObjectTexture() const { return (myFlags & Graphic3d_CappingFlags_ObjectTexture) != 0; }
//! Set flag for controlling the source of capping plane texture.
void SetUseObjectTexture (bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectTexture); }
//! Flag indicating whether shader program for capping plane should be taken from object.
//! Default value: FALSE.
bool ToUseObjectShader() const { return (myFlags & Graphic3d_CappingFlags_ObjectShader) != 0; }
//! Set flag for controlling the source of capping plane shader program.
void SetUseObjectShader(bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectShader); }
//! Return true if some fill area aspect properties should be taken from object.
bool ToUseObjectProperties() const { return myFlags != Graphic3d_CappingFlags_None; }
public:
@@ -352,14 +294,25 @@ public: // @name modification counters
{
return myAspectMod;
}
//! Flag indicating whether section style of the plane should overrides similar property of object presentation.
//! Default value: FALSE (use dedicated presentation aspect style).
bool ToOverrideCappingAspect() const { return myOverrideObjectStyle; }
//! Sets flag for controlling the preference of using section style between clip plane and object.
void SetToOverrideCappingAspect (const bool theToOverride) { myOverrideObjectStyle = theToOverride; }
//! Returns plane's orientation matrix.
Standard_EXPORT const Graphic3d_Mat4& OrientationMatrix() const;
private:
//! Generate unique object id for OpenGL graphic resource manager.
void makeId();
//! Set capping flag.
Standard_EXPORT void setCappingFlag (bool theToUse, int theFlag);
//! Initializes plane and makes unique identifier (UID) to differentiate clipping plane entities.
void init (const gp_Pln& thePlane = gp_Pln(),
const Graphic3d_Vec4d& theEquationRev = Graphic3d_Vec4d(0.0, 0.0,-1.0, 0.0),
const Standard_Boolean theIsOn = Standard_True,
const Standard_Boolean theIsCapping = Standard_False,
const Standard_Boolean theOverrideStyle = Standard_False,
const Handle(Graphic3d_AspectFillCapping)& theStyle = Handle(Graphic3d_AspectFillCapping)());
//! Update chain length in backward direction.
void updateChainLen();
@@ -374,10 +327,10 @@ private:
private:
Handle(Graphic3d_AspectFillArea3d) myAspect; //!< fill area aspect
Handle(Graphic3d_AspectFillCapping) mySectionStyle; //!< Style set for drawing capped solid section.
Handle(Graphic3d_ClipPlane) myNextInChain; //!< next plane in a chain of planes defining logical AND operation
Graphic3d_ClipPlane* myPrevInChain; //!< previous plane in a chain of planes defining logical AND operation
TCollection_AsciiString myId; //!< resource id
TCollection_AsciiString myEntityUID; //!< Unique identifier for the plane
gp_Pln myPlane; //!< plane definition
Graphic3d_Vec4d myEquation; //!< plane equation vector
Graphic3d_Vec4d myEquationRev; //!< reversed plane equation
@@ -387,6 +340,9 @@ private:
unsigned int myAspectMod; //!< modification counter of aspect
Standard_Boolean myIsOn; //!< state of the clipping plane
Standard_Boolean myIsCapping; //!< state of graphic driver capping
Standard_Boolean myOverrideObjectStyle; //!< Flag forcing to use plane's section style rather than section style defined for object
mutable Standard_Boolean myOrientationDirty; //!< Boolean flag indicating whether orientation matrix is dirty or not.
mutable Graphic3d_Mat4 myOrientationMat; //!< Plane orientation matrix (for visualization purposes).
};

View File

@@ -231,10 +231,11 @@ Standard_Boolean Graphic3d_Group::IsGroupPrimitivesAspectSet (const Graphic3d_Gr
// function : GroupPrimitivesAspect
// purpose :
// =======================================================================
void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
const Handle(Graphic3d_AspectText3d)& theAspText,
const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const
void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
const Handle(Graphic3d_AspectText3d)& theAspText,
const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
const Handle(Graphic3d_AspectFillArea3d)& theAspFill,
const Handle(Graphic3d_AspectFillCapping)& theAspCapping) const
{
if (!theAspLine.IsNull())
{
@@ -271,6 +272,15 @@ void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d
*theAspFill.operator->() = *aFillAspect;
}
}
if (!theAspCapping.IsNull())
{
Handle(Graphic3d_AspectFillCapping) aCappingAspect = FillCappingAspect();
if (!aCappingAspect.IsNull())
{
*theAspCapping.operator->() = *aCappingAspect;
}
}
}
// =======================================================================

View File

@@ -17,30 +17,30 @@
#ifndef _Graphic3d_Group_HeaderFile
#define _Graphic3d_Group_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Graphic3d_BndBox4f.hxx>
#include <Standard_Boolean.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_AspectFillCapping.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Real.hxx>
#include <Standard_CString.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_TextPath.hxx>
#include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <Graphic3d_TypeOfPrimitiveArray.hxx>
#include <Graphic3d_IndexBuffer.hxx>
#include <Graphic3d_Buffer.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_BndBox4f.hxx>
#include <Graphic3d_BoundBuffer.hxx>
#include <Standard_Address.hxx>
#include <Graphic3d_Buffer.hxx>
#include <Graphic3d_GroupAspect.hxx>
#include <gp_Ax2.hxx>
#include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Graphic3d_IndexBuffer.hxx>
#include <Graphic3d_TextPath.hxx>
#include <Graphic3d_TypeOfPrimitiveArray.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <Standard_Transient.hxx>
#include <Standard.hxx>
#include <Standard_Address.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_CString.hxx>
#include <Standard_Real.hxx>
#include <Standard_Type.hxx>
#include <TCollection_ExtendedString.hxx>
#include <gp_Ax2.hxx>
class Graphic3d_Structure;
class Graphic3d_ArrayOfPrimitives;
@@ -56,7 +56,7 @@ class Graphic3d_ArrayOfPrimitives;
//! 1) Non-modifiable, or unbounded, group ('black box').
//! Developers can repeat a sequence of
//! SetPrimitivesAspect() with AddPrimitiveArray() methods arbitrary number of times
//! to define arbitrary number of primitive "blocks" each having individual apect values.
//! to define arbitrary number of primitive "blocks" each having individual aspect values.
//! Any modification of such a group is forbidden, as aspects and primitives are mixed
//! in memory without any high-level logical structure, and any modification is very likely to result
//! in corruption of the group internal data.
@@ -82,7 +82,7 @@ class Graphic3d_Group : public Standard_Transient
public:
//! Supress all primitives and attributes of <me>.
//! Suppress all primitives and attributes of <me>.
//! To clear group without update in Graphic3d_StructureManager
//! pass Standard_False as <theUpdateStructureMgr>. This
//! used on context and viewer destruction, when the pointer
@@ -91,13 +91,13 @@ public:
//! cross-reference);
Standard_EXPORT virtual void Clear (const Standard_Boolean theUpdateStructureMgr = Standard_True);
//! Supress the group <me> in the structure.
//! Suppress the group <me> in the structure.
Standard_EXPORT virtual ~Graphic3d_Group();
//! Supress the group <me> in the structure.
//! Suppress the group <me> in the structure.
//! Warning: No more graphic operations in <me> after this call.
//! Modifies the current modelling transform persistence (pan, zoom or rotate)
//! Get the current modelling transform persistence (pan, zoom or rotate)
//! Modifies the current modeling transform persistence (pan, zoom or rotate)
//! Get the current modeling transform persistence (pan, zoom or rotate)
Standard_EXPORT void Remove();
public:
@@ -126,6 +126,12 @@ public:
//! Modifies the context for all the marker primitives of the group.
virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) = 0;
//! Returns style of filling clipping sections on closed shell primitives.
virtual Handle(Graphic3d_AspectFillCapping) FillCappingAspect() const = 0;
//! Modifies the context for filling clipping section for all closed shell primitives of the group.
virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect) = 0;
//! Modifies the current context of the group to give
//! another aspect for all the line primitives created
//! after this call in the group.
@@ -153,15 +159,17 @@ public:
Standard_EXPORT void GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
const Handle(Graphic3d_AspectText3d)& theAspText,
const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const;
const Handle(Graphic3d_AspectFillArea3d)& theAspFill,
const Handle(Graphic3d_AspectFillCapping)& theAspFillCapping) const;
//! Returns the last inserted context in the group for each kind of primitives.
void PrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
const Handle(Graphic3d_AspectText3d)& theAspText,
const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const
const Handle(Graphic3d_AspectFillArea3d)& theAspFill,
const Handle(Graphic3d_AspectFillCapping)& theAspFillCapping) const
{
GroupPrimitivesAspect (theAspLine, theAspText, theAspMarker, theAspFill);
GroupPrimitivesAspect (theAspLine, theAspText, theAspMarker, theAspFill, theAspFillCapping);
}
public:

View File

@@ -21,13 +21,15 @@
//! - ASPECT_LINE: aspect for line primitives;
//! - ASPECT_TEXT: aspect for text primitives;
//! - ASPECT_MARKER: aspect for marker primitives;
//! - ASPECT_FILL_AREA: aspect for face primitives.
//! - ASPECT_FILL_AREA: aspect for face primitives;
//! - Graphic3d_ASPECT_FILL_CAPPING: aspect for filling clipping sections.
enum Graphic3d_GroupAspect
{
Graphic3d_ASPECT_LINE,
Graphic3d_ASPECT_TEXT,
Graphic3d_ASPECT_MARKER,
Graphic3d_ASPECT_FILL_AREA
Graphic3d_ASPECT_FILL_AREA,
Graphic3d_ASPECT_FILL_CAPPING
};
#endif // _Graphic3d_GroupAspect_HeaderFile

View File

@@ -291,7 +291,7 @@ public:
//! Compute per-element multiplication.
//! @param theFactor [in] the scale factor.
//! @return the result of multiplicaton.
//! @return the result of multiplication.
NCollection_Mat4 operator* (const Element_t theFactor) const
{
return Multiplied (theFactor);
@@ -299,7 +299,7 @@ public:
//! Compute per-element multiplication.
//! @param theFactor [in] the scale factor.
//! @return the result of multiplicaton.
//! @return the result of multiplication.
NCollection_Mat4 Multiplied (const Element_t theFactor) const
{
NCollection_Mat4 aTempMat (*this);

View File

@@ -21,11 +21,16 @@
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_CappingPlaneResource.hxx>
#include <OpenGl_Vec.hxx>
#include <OpenGl_View.hxx>
#include <OpenGl_Structure.hxx>
#include <OpenGl_ShaderManager.hxx>
namespace
{
static const OpenGl_CappingPlaneResource THE_DEFAULT_ASPECT = OpenGl_CappingPlaneResource (new Graphic3d_AspectFillCapping);
static const TCollection_AsciiString THE_QUAD_PARRAY = "OpenGl_CappingAlgo_Quad";
static const TCollection_AsciiString THE_PLANE_STYLE = "OpenGl_CappingAlgo_CappingStyle_";
//! Auxiliary sentry object managing stencil test.
struct StencilTestSentry
{
@@ -58,21 +63,113 @@ namespace
GLint myDepthFuncPrev;
};
//! Render infinite capping plane.
//! @param theWorkspace [in] the GL workspace, context state.
//! @param thePlane [in] the graphical plane, for which the capping surface is rendered.
static void renderPlane (const Handle(OpenGl_Workspace)& theWorkspace,
const Handle(OpenGl_CappingPlaneResource)& thePlane)
class OpenGl_SharedElement : public OpenGl_Resource
{
public:
OpenGl_SharedElement (OpenGl_Element* theGlElement) : myGlElement (theGlElement) {}
virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE
{
OpenGl_Element::Destroy (theGlCtx, myGlElement);
}
OpenGl_Element* GlElement() const { return myGlElement; }
//! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
Standard_Size EstimatedDataSize() const Standard_OVERRIDE { return 0; }
private:
OpenGl_Element* myGlElement;
public:
DEFINE_STANDARD_RTTI_INLINE (OpenGl_SharedElement, OpenGl_Resource)
};
//! Iitializes and returns vertex buffer for plane section
OpenGl_PrimitiveArray* initQuad (const Handle(OpenGl_Context)& theContext)
{
Handle(OpenGl_SharedElement) aSharedResource;
if (!theContext->GetResource (THE_QUAD_PARRAY, aSharedResource))
{
aSharedResource = new OpenGl_SharedElement (OpenGl_CappingPlaneResource::BuildInfinitPlaneVertices());
theContext->ShareResource (THE_QUAD_PARRAY, aSharedResource);
}
return dynamic_cast<OpenGl_PrimitiveArray*> (aSharedResource->GlElement());
}
//! Render section plane using the given aspects.
void renderSection (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_PrimitiveArray* theQuad,
const OpenGl_AspectFace* theCappingAspect,
const OpenGl_AspectFace* theHatchAspect,
const OpenGl_Mat4& theCappingMatrix,
const Standard_ShortReal theHatchScale,
const Standard_ShortReal theHatchRotate)
{
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
const bool wasCullAllowed = theWorkspace->SetAllowFaceCulling (true);
// set identity model matrix
const Standard_Boolean isTextureHatch =
theHatchAspect != NULL
&& theHatchAspect->Aspect()->TextureMapState();
aContext->ModelWorldState.Push();
aContext->ModelWorldState.SetCurrent (OpenGl_Mat4::Map (*thePlane->Orientation()->mat));
aContext->ModelWorldState.SetCurrent (theCappingMatrix);
aContext->ApplyModelViewMatrix();
thePlane->Primitives().Render (theWorkspace);
theWorkspace->SetAspectFace (theCappingAspect);
theWorkspace->ApplyAspectFace();
theQuad->Render (theWorkspace);
if (theHatchAspect != NULL)
{
Graphic3d_Vec2 aPrevScale;
Standard_ShortReal aPrevRotate = 0.0;
if (isTextureHatch)
{
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if ((theHatchScale != 1.0 || theHatchRotate != 0.0) && !theHatchAspect->TextureSet(aContext)->IsEmpty())
{
Handle(OpenGl_Texture) aTexture = theHatchAspect->TextureSet(aContext)->First();
const Handle(Graphic3d_TextureParams)& aTexParams = aTexture->Sampler()->Parameters();
aPrevScale = aTexParams->Scale();
aPrevRotate = aTexParams->Rotation();
const Standard_Boolean isMirror = aPrevScale.x() * aPrevScale.y() < 0.0;
aTexParams->SetScale (aPrevScale * theHatchScale);
aTexParams->SetRotation (isMirror ? aPrevRotate - theHatchRotate : aPrevRotate + theHatchRotate);
}
}
theWorkspace->SetAspectFace (theHatchAspect);
theWorkspace->ApplyAspectFace();
glDepthFunc (GL_LEQUAL);
theQuad->Render (theWorkspace);
glDepthFunc (GL_LESS);
if (isTextureHatch)
{
glDisable (GL_BLEND);
if (theHatchScale != 1.0 || theHatchRotate != 0.0)
{
Handle(OpenGl_Texture) aTexture = theHatchAspect->TextureSet(aContext)->First();
const Handle(Graphic3d_TextureParams)& aTexParams = aTexture->Sampler()->Parameters();
aTexParams->SetScale (aPrevScale);
aTexParams->SetRotation (aPrevRotate);
}
}
}
aContext->ModelWorldState.Pop();
aContext->ApplyModelViewMatrix();
@@ -86,13 +183,23 @@ namespace
const OpenGl_Structure& theStructure,
const Handle(Graphic3d_ClipPlane)& theClipChain,
const Standard_Integer theSubPlaneIndex,
const Handle(OpenGl_CappingPlaneResource)& thePlane)
const Handle(OpenGl_CappingPlaneResource)& thePlane,
const OpenGl_PrimitiveArray* theQuad)
{
const Standard_Integer aPrevFilter = theWorkspace->RenderFilter();
const Standard_Integer anAnyFilter = aPrevFilter & ~(Standard_Integer )(OpenGl_RenderFilter_OpaqueOnly | OpenGl_RenderFilter_TransparentOnly);
const Handle(Graphic3d_ClipPlane)& aPlane = theClipChain;
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
const Handle(Graphic3d_ClipPlane)& aRenderPlane = thePlane->Plane();
const Handle(Graphic3d_Camera) aCamera = theWorkspace->View() != NULL
? theWorkspace->View()->Camera()
: Handle(Graphic3d_Camera)();
const OpenGl_Mat4& aPlaneMat = OpenGl_Mat4::Map (aPlane->OrientationMatrix());
Standard_ShortReal aRotateAngle = 0.0;
Standard_ShortReal aViewScale = ShortRealLast();
OpenGl_Mat4 aRotateZoomMat;
for (OpenGl_Structure::GroupIterator aGroupIter (theStructure.Groups()); aGroupIter.More(); aGroupIter.Next())
{
if (!aGroupIter.Value()->IsClosed())
@@ -103,16 +210,6 @@ namespace
// clear stencil only if something has been actually drawn
theStencilSentry.Init();
// check if capping plane should be rendered within current pass (only opaque / only transparent)
const OpenGl_AspectFace* anObjAspectFace = aRenderPlane->ToUseObjectProperties() ? aGroupIter.Value()->AspectFace() : NULL;
thePlane->Update (aContext, anObjAspectFace != NULL ? anObjAspectFace->Aspect() : Handle(Graphic3d_AspectFillArea3d)());
theWorkspace->SetAspectFace (thePlane->AspectFace());
theWorkspace->SetRenderFilter (aPrevFilter);
if (!theWorkspace->ShouldRender (&thePlane->Primitives()))
{
continue;
}
// suppress only opaque/transparent filter since for filling stencil the whole geometry should be drawn
theWorkspace->SetRenderFilter (anAnyFilter);
@@ -121,7 +218,7 @@ namespace
aContext->ShaderManager()->UpdateClippingState();
glClear (GL_STENCIL_BUFFER_BIT);
const bool aColorMaskBack = aContext->SetColorMask (false);
glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
// override aspects, disable culling
theWorkspace->SetAspectFace (&theWorkspace->NoneCulling());
@@ -140,20 +237,7 @@ namespace
glStencilOp (GL_KEEP, GL_INVERT, GL_INVERT);
// render closed primitives
if (aRenderPlane->ToUseObjectProperties())
{
aGroupIter.Value()->Render (theWorkspace);
}
else
{
for (; aGroupIter.More(); aGroupIter.Next())
{
if (aGroupIter.Value()->IsClosed())
{
aGroupIter.Value()->Render (theWorkspace);
}
}
}
aGroupIter.Value()->Render (theWorkspace);
// override material, cull back faces
theWorkspace->SetAspectFace (&theWorkspace->FrontCulling());
@@ -164,7 +248,7 @@ namespace
aContext->ShaderManager()->UpdateClippingState();
// render capping plane using the generated stencil mask
aContext->SetColorMask (aColorMaskBack);
glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
if (theWorkspace->UseDepthWrite())
{
glDepthMask (GL_TRUE);
@@ -176,8 +260,66 @@ namespace
glEnable (GL_DEPTH_TEST);
}
theWorkspace->SetAspectFace (thePlane->AspectFace());
renderPlane (theWorkspace, thePlane);
const OpenGl_AspectFace* aGroupAspectFace = aGroupIter.Value()->AspectFace();
const OpenGl_CappingPlaneResource* aGroupAspectCapping = aGroupIter.Value()->AspectFillCapping();
const OpenGl_CappingPlaneResource* anAspectCapping =
thePlane && (!aGroupAspectCapping || aGroupAspectCapping->Aspect().IsNull() || aPlane->ToOverrideCappingAspect())
? thePlane.get()
: aGroupAspectCapping;
if (anAspectCapping == NULL)
{
anAspectCapping = &THE_DEFAULT_ASPECT;
}
const OpenGl_AspectFace* anAspectFace = anAspectCapping->CappingFaceAspect (aGroupAspectFace);
const Standard_Boolean hasHatch = anAspectCapping->Aspect()->ToDrawHatch();
const OpenGl_AspectFace* anAspectHatching = hasHatch ? anAspectCapping->HatchingFaceAspect() : NULL;
const Standard_Boolean hasTextureHatch = hasHatch && !anAspectCapping->Aspect()->TextureHatch().IsNull();
const Standard_Boolean isRotatePers = hasTextureHatch && !aCamera.IsNull() && anAspectCapping->Aspect()->IsHatchRotationPersistent();
const Standard_Boolean isZoomPers = hasTextureHatch && !aCamera.IsNull() && anAspectCapping->Aspect()->IsHatchZoomPersistent();
Standard_ShortReal aHatchScale = 1.0;
Standard_ShortReal aHatchAngle = 0.0;
if (isRotatePers || isZoomPers)
{
if (isRotatePers)
{
if (aRotateAngle == 0.0)
{
const gp_Dir aPlaneSide (aPlaneMat.GetValue (0, 0), aPlaneMat.GetValue (1, 0), aPlaneMat.GetValue (2, 0));
const gp_Dir aPlaneUp (aPlaneMat.GetValue (0, 2), aPlaneMat.GetValue (1, 2), aPlaneMat.GetValue (2, 2));
const gp_Dir& aCameraUp = aCamera->Up();
const gp_Vec aCameraPln = aPlaneSide.Dot (aCameraUp) * aPlaneSide + aPlaneUp.Dot (aCameraUp) * aPlaneUp;
const gp_Dir& aCameraDir = aCamera->Direction();
aRotateAngle = static_cast<Standard_ShortReal> (aCameraPln.AngleWithRef (aPlaneUp, aCameraDir) / M_PI * 180.0);
}
aHatchAngle = aRotateAngle;
}
if (isZoomPers)
{
if (aViewScale == ShortRealLast())
{
const Standard_Real aFocus = aCamera->IsOrthographic()
? aCamera->Distance()
: (aCamera->ZFocusType() == Graphic3d_Camera::FocusType_Relative
? Standard_Real(aCamera->ZFocus() * aCamera->Distance())
: Standard_Real(aCamera->ZFocus()));
const gp_XYZ aViewDim = aCamera->ViewDimensions (aFocus);
aViewScale = static_cast<Standard_ShortReal> (aViewDim.Y() / aContext->Viewport()[3]);
}
if (!anAspectHatching->TextureSet(aContext)->IsEmpty())
aHatchScale = 1.0f / (aViewScale * anAspectHatching->TextureSet(aContext)->First()->SizeY());
}
}
renderSection (theWorkspace, theQuad, anAspectFace, hasHatch ? anAspectCapping->HatchingFaceAspect() : NULL, aPlaneMat, aHatchScale, aHatchAngle);
// turn on the current plane to restore initial state
aContext->ChangeClipping().ResetCappingFilter();
@@ -187,7 +329,7 @@ namespace
if (theStructure.InstancedStructure() != NULL)
{
renderCappingForStructure (theStencilSentry, theWorkspace, *theStructure.InstancedStructure(), theClipChain, theSubPlaneIndex, thePlane);
renderCappingForStructure (theStencilSentry, theWorkspace, *theStructure.InstancedStructure(), theClipChain, theSubPlaneIndex, thePlane, theQuad);
}
}
}
@@ -206,6 +348,12 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
return;
}
const OpenGl_PrimitiveArray* aCappingQuad = initQuad (aContext);
if (!aCappingQuad)
{
return;
}
// remember current aspect face defined in workspace
const OpenGl_AspectFace* aFaceAsp = theWorkspace->AspectFace();
@@ -214,6 +362,16 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
theWorkspace->SetRenderFilter (aPrevFilter | OpenGl_RenderFilter_FillModeOnly);
StencilTestSentry aStencilSentry;
GLboolean aPrevBlend = glIsEnabled (GL_BLEND);
GLint aPrevBlendSrc = GL_ONE;
GLint aPrevBlendDst = GL_ZERO;
if (aPrevBlend == GL_TRUE)
{
glGetIntegerv (GL_BLEND_SRC_ALPHA, &aPrevBlendSrc);
glGetIntegerv (GL_BLEND_DST_ALPHA, &aPrevBlendDst);
glDisable (GL_BLEND);
}
// generate capping for every clip plane
for (OpenGl_ClippingIterator aCappingIt (aContext->Clipping()); aCappingIt.More(); aCappingIt.Next())
{
@@ -229,23 +387,33 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
for (const Graphic3d_ClipPlane* aSubPlaneIter = aClipChain.get(); aSubPlaneIter != NULL; aSubPlaneIter = aSubPlaneIter->ChainNextPlane().get(), ++aSubPlaneIndex)
{
// get resource for the plane
const TCollection_AsciiString& aResId = aSubPlaneIter->GetId();
const TCollection_AsciiString& aResId = THE_PLANE_STYLE + aSubPlaneIter->GetId();
Handle(OpenGl_CappingPlaneResource) aPlaneRes;
if (!aContext->GetResource (aResId, aPlaneRes))
{
// share and register for release once the resource is no longer used
aPlaneRes = new OpenGl_CappingPlaneResource (aSubPlaneIter);
aPlaneRes = new OpenGl_CappingPlaneResource (aSubPlaneIter->CappingSectionStyle());
aContext->ShareResource (aResId, aPlaneRes);
}
renderCappingForStructure (aStencilSentry, theWorkspace, theStructure, aClipChain, aSubPlaneIndex, aPlaneRes);
renderCappingForStructure (aStencilSentry, theWorkspace, theStructure, aClipChain, aSubPlaneIndex, aPlaneRes, aCappingQuad);
// set delayed resource release
aPlaneRes.Nullify();
aContext->ReleaseResource (aResId, Standard_True);
if (!aResId.IsEmpty())
{
// schedule release of resource if not used
aContext->ReleaseResource (aResId, Standard_True);
}
}
}
if (aPrevBlend == GL_TRUE)
{
glEnable (GL_BLEND);
glBlendFunc (aPrevBlendSrc, aPrevBlendDst);
}
// restore rendering aspects
theWorkspace->SetAspectFace (aFaceAsp);
theWorkspace->SetRenderFilter (aPrevFilter);

View File

@@ -55,21 +55,28 @@ namespace
{ 0.0f, 0.0f, 0.0f, 1.0f } }
};
Handle(Graphic3d_AspectFillArea3d) defaultMaterial()
{
Handle(Graphic3d_AspectFillArea3d) anAspect;
const Graphic3d_MaterialAspect aMaterial (Graphic3d_NOM_DEFAULT);
anAspect = new Graphic3d_AspectFillArea3d();
anAspect->SetDistinguishOff();
anAspect->SetFrontMaterial (aMaterial);
anAspect->SetInteriorStyle (Aspect_IS_SOLID);
anAspect->SetInteriorColor (aMaterial.Color());
anAspect->SetSuppressBackFaces (false);
return anAspect;
}
}
// =======================================================================
// function : OpenGl_CappingPlaneResource
// function : BuildInfinitPlaneVertices
// purpose :
// =======================================================================
OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane)
: myPrimitives (NULL),
myOrientation (OpenGl_IdentityMatrix),
myAspect (NULL),
myPlaneRoot (thePlane),
myEquationMod ((unsigned int )-1),
myAspectMod ((unsigned int )-1)
OpenGl_PrimitiveArray* OpenGl_CappingPlaneResource::BuildInfinitPlaneVertices()
{
OpenGl_PrimitiveArray* aPrimitives = NULL;
// Fill primitive array
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (anAlloc);
@@ -82,8 +89,23 @@ OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d
if (anAttribs->Init (12, anAttribInfo, 3))
{
memcpy (anAttribs->ChangeData(), THE_CAPPING_PLN_VERTS, sizeof(THE_CAPPING_PLN_VERTS));
myPrimitives.InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
aPrimitives = new OpenGl_PrimitiveArray (NULL);
aPrimitives->InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
}
return aPrimitives;
}
// =======================================================================
// function : OpenGl_CappingPlaneResource
// purpose :
// =======================================================================
OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_AspectFillCapping)& theAspect)
: myCappingAspect (defaultMaterial()),
myHatchingAspect (defaultMaterial()),
myHatchingState (0)
{
SetAspect (theAspect);
}
// =======================================================================
@@ -92,18 +114,83 @@ OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d
// =======================================================================
OpenGl_CappingPlaneResource::~OpenGl_CappingPlaneResource()
{
Release (NULL);
}
// =======================================================================
// function : Update
// function : SetAspect
// purpose :
// =======================================================================
void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& ,
const Handle(Graphic3d_AspectFillArea3d)& theObjAspect)
void OpenGl_CappingPlaneResource::SetAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect)
{
updateTransform();
updateAspect (theObjAspect);
myAspect = theAspect;
if (theAspect.IsNull())
{
return;
}
if (!theAspect->ToUseObjectMaterial()
|| !theAspect->ToUseObjectTexture()
|| !theAspect->ToUseObjectShader())
{
Handle(Graphic3d_AspectFillArea3d) aFillAspect = myCappingAspect.Aspect();
if (!theAspect->ToUseObjectMaterial())
{
aFillAspect->SetFrontMaterial (theAspect->Material());
aFillAspect->SetInteriorColor (theAspect->Material().Color());
}
if (!theAspect->ToUseObjectTexture())
{
aFillAspect->SetTextureMap (theAspect->Texture());
if (!theAspect->Texture().IsNull())
{
aFillAspect->SetTextureMapOn();
}
else
{
aFillAspect->SetTextureMapOff();
}
}
else
{
aFillAspect->SetTextureMap (Handle(Graphic3d_TextureMap)());
aFillAspect->SetTextureMapOff();
}
if (!theAspect->ToUseObjectShader())
{
aFillAspect->SetShaderProgram (theAspect->Shader());
}
myCappingAspect.SetAspect (aFillAspect);
}
if (theAspect->ToDrawHatch()
&& (theAspect->IsTextureHatch()
|| theAspect->IsStippleHatch()))
{
Handle(Graphic3d_AspectFillArea3d) aFillAspect = myHatchingAspect.Aspect();
aFillAspect->SetInteriorStyle (theAspect->IsStippleHatch() ? Aspect_IS_HATCH : Aspect_IS_SOLID);
aFillAspect->SetHatchStyle (theAspect->IsStippleHatch() ? theAspect->StippleHatch() : Handle(Graphic3d_HatchStyle)());
aFillAspect->SetTextureMap (theAspect->IsTextureHatch() ? theAspect->TextureHatch() : Handle(Graphic3d_TextureMap)());
aFillAspect->SetFrontMaterial (theAspect->HatchMaterial());
aFillAspect->SetInteriorColor (theAspect->HatchMaterial().Color());
if (theAspect->IsTextureHatch())
{
aFillAspect->SetTextureMapOn();
}
else
{
aFillAspect->SetTextureMapOff();
}
myHatchingAspect.SetAspect (aFillAspect);
myHatchingState = theAspect->HatchingState();
}
}
// =======================================================================
@@ -112,133 +199,110 @@ void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& ,
// =======================================================================
void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext)
{
OpenGl_Element::Destroy (theContext, myAspect);
myPrimitives.Release (theContext);
myEquationMod = (unsigned int )-1;
myAspectMod = (unsigned int )-1;
myCappingAspect .Release (theContext);
myHatchingAspect.Release (theContext);
}
// =======================================================================
// function : updateAspect
// function : CappingFaceAspect
// purpose :
// =======================================================================
void OpenGl_CappingPlaneResource::updateAspect (const Handle(Graphic3d_AspectFillArea3d)& theObjAspect)
const OpenGl_AspectFace* OpenGl_CappingPlaneResource::CappingFaceAspect (const OpenGl_AspectFace* theObjectAspect) const
{
if (myAspect == NULL)
if (myAspect.IsNull())
{
myAspect = new OpenGl_AspectFace();
myAspectMod = myPlaneRoot->MCountAspect() - 1; // mark out of sync
return NULL;
}
if (theObjAspect.IsNull())
{
if (myAspectMod != myPlaneRoot->MCountAspect())
{
myAspect->SetAspect (myPlaneRoot->CappingAspect());
myAspectMod = myPlaneRoot->MCountAspect();
}
return;
}
Handle(Graphic3d_AspectFillArea3d) aFillAspect = myCappingAspect.Aspect();
if (myFillAreaAspect.IsNull())
{
myFillAreaAspect = new Graphic3d_AspectFillArea3d();
}
if (myAspectMod != myPlaneRoot->MCountAspect())
{
*myFillAreaAspect = *myPlaneRoot->CappingAspect();
}
if (myPlaneRoot->ToUseObjectMaterial())
if (myAspect->ToUseObjectMaterial() && theObjectAspect != NULL)
{
// only front material currently supported by capping rendering
myFillAreaAspect->SetFrontMaterial (theObjAspect->FrontMaterial());
myFillAreaAspect->SetInteriorColor (theObjAspect->InteriorColor());
}
if (myPlaneRoot->ToUseObjectTexture())
{
myFillAreaAspect->SetTextureSet (theObjAspect->TextureSet());
if (theObjAspect->ToMapTexture())
{
myFillAreaAspect->SetTextureMapOn();
}
else
{
myFillAreaAspect->SetTextureMapOff();
}
}
if (myPlaneRoot->ToUseObjectShader())
{
myFillAreaAspect->SetShaderProgram (theObjAspect->ShaderProgram());
}
myAspect->SetAspect (myFillAreaAspect);
}
// =======================================================================
// function : updateTransform
// purpose :
// =======================================================================
void OpenGl_CappingPlaneResource::updateTransform()
{
const Graphic3d_ClipPlane::Equation& anEquation = myPlaneRoot->GetEquation();
if (myEquationMod == myPlaneRoot->MCountEquation())
{
return; // nothing to update
}
// re-evaluate infinite plane transformation matrix
Standard_ShortReal N[3] =
{ (Standard_ShortReal)anEquation[0],
(Standard_ShortReal)anEquation[1],
(Standard_ShortReal)anEquation[2] };
Standard_ShortReal T[3] =
{ (Standard_ShortReal)(anEquation[0] * -anEquation[3]),
(Standard_ShortReal)(anEquation[1] * -anEquation[3]),
(Standard_ShortReal)(anEquation[2] * -anEquation[3]) };
Standard_ShortReal L[3] = { 0.0f, 0.0f, 0.0f };
Standard_ShortReal F[3] = { 0.0f, 0.0f, 0.0f };
// project plane normal onto OX to find left vector
Standard_ShortReal aProjLen =
sqrt ( (Standard_ShortReal)(anEquation[0] * anEquation[0])
+ (Standard_ShortReal)(anEquation[2] * anEquation[2]));
if (aProjLen < ShortRealSmall())
{
L[0] = 1.0f;
aFillAspect->SetFrontMaterial (theObjectAspect->Aspect()->FrontMaterial());
aFillAspect->SetInteriorColor (theObjectAspect->Aspect()->InteriorColor());
}
else
{
L[0] = N[2] / aProjLen;
L[2] = -N[0] / aProjLen;
aFillAspect->SetFrontMaterial (myAspect->Material());
aFillAspect->SetInteriorColor (myAspect->Material().Color());
}
// (-aLeft) x aNorm
F[0] = (-L[1])*N[2] - (-L[2])*N[1];
F[1] = (-L[2])*N[0] - (-L[0])*N[2];
F[2] = (-L[0])*N[1] - (-L[1])*N[0];
if (myAspect->ToUseObjectTexture() && theObjectAspect != NULL)
{
if (theObjectAspect->Aspect()->ToMapTexture())
{
aFillAspect->SetTextureMap (theObjectAspect->Aspect()->TextureMap());
aFillAspect->SetTextureMapOn();
}
else
{
aFillAspect->SetTextureMapOff();
}
}
else
{
aFillAspect->SetTextureMap (myAspect->Texture());
if (!myAspect->Texture().IsNull())
{
aFillAspect->SetTextureMapOn();
}
else
{
aFillAspect->SetTextureMapOff();
}
}
myOrientation.mat[0][0] = L[0];
myOrientation.mat[0][1] = L[1];
myOrientation.mat[0][2] = L[2];
myOrientation.mat[0][3] = 0.0f;
if (myAspect->ToUseObjectShader() && theObjectAspect != NULL)
{
aFillAspect->SetShaderProgram (theObjectAspect->Aspect()->ShaderProgram());
}
else
{
aFillAspect->SetShaderProgram (myAspect->Shader());
}
myOrientation.mat[1][0] = N[0];
myOrientation.mat[1][1] = N[1];
myOrientation.mat[1][2] = N[2];
myOrientation.mat[1][3] = 0.0f;
myCappingAspect.SetAspect (aFillAspect);
myOrientation.mat[2][0] = F[0];
myOrientation.mat[2][1] = F[1];
myOrientation.mat[2][2] = F[2];
myOrientation.mat[2][3] = 0.0f;
myOrientation.mat[3][0] = T[0];
myOrientation.mat[3][1] = T[1];
myOrientation.mat[3][2] = T[2];
myOrientation.mat[3][3] = 1.0f;
myEquationMod = myPlaneRoot->MCountEquation();
return &myCappingAspect;
}
// =======================================================================
// function : HatchingFaceAspect
// purpose :
// =======================================================================
const OpenGl_AspectFace* OpenGl_CappingPlaneResource::HatchingFaceAspect() const
{
if (myAspect.IsNull())
{
return NULL;
}
const Standard_Size aHatchingState = myAspect->HatchingState();
if (myHatchingState != aHatchingState)
{
if (myAspect->ToDrawHatch())
{
Handle(Graphic3d_AspectFillArea3d) aFillAspect = myHatchingAspect.Aspect();
aFillAspect->SetInteriorStyle (myAspect->IsStippleHatch() ? Aspect_IS_HATCH : Aspect_IS_SOLID);
aFillAspect->SetHatchStyle (myAspect->IsStippleHatch() ? myAspect->StippleHatch() : Handle(Graphic3d_HatchStyle)());
aFillAspect->SetTextureMap (myAspect->IsTextureHatch() ? myAspect->TextureHatch() : Handle(Graphic3d_TextureMap)());
aFillAspect->SetFrontMaterial (myAspect->HatchMaterial());
aFillAspect->SetInteriorColor (myAspect->HatchMaterial().Color());
if (myAspect->IsTextureHatch())
{
aFillAspect->SetTextureMapOn();
}
else
{
aFillAspect->SetTextureMapOff();
}
myHatchingAspect.SetAspect (aFillAspect);
myHatchingState = aHatchingState;
}
}
return &myHatchingAspect;
}

View File

@@ -20,7 +20,7 @@
#include <OpenGl_Resource.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_Matrix.hxx>
#include <Graphic3d_ClipPlane.hxx>
#include <Graphic3d_AspectFillCapping.hxx>
class OpenGl_CappingPlaneResource;
DEFINE_STANDARD_HANDLE (OpenGl_CappingPlaneResource, OpenGl_Resource)
@@ -30,25 +30,23 @@ DEFINE_STANDARD_HANDLE (OpenGl_CappingPlaneResource, OpenGl_Resource)
//! This resource holds data necessary for OpenGl_CappingAlgo.
//! This object is implemented as OpenGl resource for the following reasons:
//! - one instance should be shared between contexts.
//! - instance associated to Graphic3d_ClipPlane data by id.
//! - instance associated to Graphic3d_AspectFillCapping data.
//! - should created and released within context (owns OpenGl elements and resources).
class OpenGl_CappingPlaneResource : public OpenGl_Resource
{
public:
//! Constructor.
//! Create capping plane presentation associated to clipping plane data.
//! @param thePlane [in] the plane data.
Standard_EXPORT OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane);
//! Create and assign style.
Standard_EXPORT OpenGl_CappingPlaneResource (const Handle(Graphic3d_AspectFillCapping)& theAspect);
//! Destroy object.
Standard_EXPORT virtual ~OpenGl_CappingPlaneResource();
//! Update resource data in the passed context.
//! @param theContext [in] the context
//! @param theObjAspect [in] object aspect
Standard_EXPORT void Update (const Handle(OpenGl_Context)& theContext,
const Handle(Graphic3d_AspectFillArea3d)& theObjAspect);
//! Assign section style.
Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect);
//! Returns section style parameters.
const Handle(Graphic3d_AspectFillCapping)& Aspect() const { return myAspect; }
//! Release associated OpenGl resources.
//! @param theContext [in] the resource context.
@@ -57,17 +55,23 @@ public:
//! Returns estimated GPU memory usage - not implemented.
virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE { return 0; }
//! Return parent clipping plane structure.
const Handle(Graphic3d_ClipPlane)& Plane() const { return myPlaneRoot; }
//! @return aspect face for rendering capping surface.
inline const OpenGl_AspectFace* AspectFace() const { return myAspect; }
//! @return evaluated orientation matrix to transform infinite plane.
inline const OpenGl_Matrix* Orientation() const { return &myOrientation; }
//! @return primitive array of vertices to render infinite plane.
inline const OpenGl_PrimitiveArray& Primitives() const { return myPrimitives; }
static OpenGl_PrimitiveArray* BuildInfinitPlaneVertices();
//! Returns true if capping should draw hatch layer.
Standard_Boolean ToDrawHatch() const
{
return myAspect->ToDrawHatch()
&& (myAspect->IsStippleHatch()
|| myAspect->IsTextureHatch());
}
//! Returns the shading aspect for drawing face of a clipping section itself.
//! @param theObjectAspect [in] the aspect of an object if it requires combining.
Standard_EXPORT const OpenGl_AspectFace* CappingFaceAspect (const OpenGl_AspectFace* theObjectAspect) const;
//! Returns the shading aspect for drawing hatch layer of a section.
Standard_EXPORT const OpenGl_AspectFace* HatchingFaceAspect() const;
private:
@@ -79,13 +83,10 @@ private:
private:
OpenGl_PrimitiveArray myPrimitives; //!< vertices and texture coordinates for rendering
OpenGl_Matrix myOrientation; //!< plane transformation matrix.
OpenGl_AspectFace* myAspect; //!< capping face aspect.
Handle(Graphic3d_ClipPlane) myPlaneRoot; //!< parent clipping plane structure.
Handle(Graphic3d_AspectFillArea3d) myFillAreaAspect; //!< own capping aspect
unsigned int myEquationMod; //!< modification counter for plane equation.
unsigned int myAspectMod; //!< modification counter for aspect.
Handle(Graphic3d_AspectFillCapping) myAspect; //!< Section style settings from application's level.
mutable OpenGl_AspectFace myCappingAspect; //!< GL aspect for shading base layer of a capping section.
mutable OpenGl_AspectFace myHatchingAspect; //!< GL aspect for shading hatching layer (additional to base) of a capping section.
mutable Standard_Size myHatchingState;
public:

View File

@@ -264,6 +264,28 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& th
Update();
}
// =======================================================================
// function : SetGroupPrimitivesAspect
// purpose :
// =======================================================================
void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect)
{
if (IsDeleted())
{
return;
}
if (myAspectFillCapping == NULL)
{
myAspectFillCapping = new OpenGl_CappingPlaneResource (theAspect);
}
else
{
myAspectFillCapping->SetAspect (theAspect);
}
Update();
}
// =======================================================================
// function : AddPrimitiveArray
// purpose :

View File

@@ -24,9 +24,11 @@
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_AspectMarker.hxx>
#include <OpenGl_AspectText.hxx>
#include <OpenGl_CappingPlaneResource.hxx>
#include <OpenGl_Element.hxx>
class OpenGl_Group;
class OpenGl_CappingPlaneResource;
class OpenGl_Structure;
struct OpenGl_ElementNode
@@ -103,6 +105,17 @@ public:
//! Append text aspect as an element.
Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspect) Standard_OVERRIDE;
//! Update section style aspect.
Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect) Standard_OVERRIDE;
//! Returns section style aspect.
virtual Handle(Graphic3d_AspectFillCapping) FillCappingAspect() const Standard_OVERRIDE
{
return myAspectFillCapping != NULL
? myAspectFillCapping->Aspect()
: Handle(Graphic3d_AspectFillCapping)();
}
//! Add primitive array element
Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
const Handle(Graphic3d_IndexBuffer)& theIndices,
@@ -153,6 +166,9 @@ public:
//! Returns OpenGL face aspect.
const OpenGl_AspectFace* AspectFace() const { return myAspectFace; }
//! Returns OpenGL capping filling aspect.
const OpenGl_CappingPlaneResource* AspectFillCapping() const { return myAspectFillCapping; }
//! Is the group ray-tracable (contains ray-tracable elements)?
Standard_Boolean IsRaytracable() const { return myIsRaytracable; }
@@ -166,6 +182,7 @@ protected:
OpenGl_AspectFace* myAspectFace;
OpenGl_AspectMarker* myAspectMarker;
OpenGl_AspectText* myAspectText;
OpenGl_CappingPlaneResource* myAspectFillCapping;
OpenGl_ElementNode* myFirst;
OpenGl_ElementNode* myLast;

View File

@@ -1249,11 +1249,11 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFont()
EOL"}";
TCollection_AsciiString
aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occSamplerBaseColor, TexCoord.st).a; }";
aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occActiveSampler, TexCoord.st).a; }";
#if !defined(GL_ES_VERSION_2_0)
if (myContext->core11 == NULL)
{
aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occSamplerBaseColor, TexCoord.st).r; }";
aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occActiveSampler, TexCoord.st).r; }";
}
#endif
@@ -1468,12 +1468,12 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramOitCompositing (const St
// =======================================================================
TCollection_AsciiString OpenGl_ShaderManager::pointSpriteAlphaSrc (const Standard_Integer theBits)
{
TCollection_AsciiString aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occSamplerBaseColor, " THE_VEC2_glPointCoord ").a; }";
TCollection_AsciiString aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occActiveSampler, " THE_VEC2_glPointCoord ").a; }";
#if !defined(GL_ES_VERSION_2_0)
if (myContext->core11 == NULL
&& (theBits & OpenGl_PO_TextureA) != 0)
{
aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occSamplerBaseColor, " THE_VEC2_glPointCoord ").r; }";
aSrcGetAlpha = EOL"float getAlpha(void) { return occTexture2D(occActiveSampler, " THE_VEC2_glPointCoord ").r; }";
}
#else
(void )theBits;
@@ -1516,7 +1516,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
if ((theBits & OpenGl_PO_TextureRGB) != 0)
{
aSrcFragGetColor =
EOL"vec4 getColor(void) { return occTexture2D(occSamplerBaseColor, " THE_VEC2_glPointCoord "); }";
EOL"vec4 getColor(void) { return occTexture2D(occActiveSampler, " THE_VEC2_glPointCoord "); }";
}
if (textureUsed (theBits))
@@ -1554,7 +1554,10 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
aSrcVertExtraMain += THE_VARY_TexCoord_Trsf;
aSrcFragGetColor =
EOL"vec4 getColor(void) { return occTexture2D(occSamplerBaseColor, TexCoord.st / TexCoord.w); }";
EOL"vec4 getColor(void)"
EOL"{"
EOL" return occTexture2D(occActiveSampler, TexCoord.st / TexCoord.w) * occColor;"
EOL"}";
}
else if ((theBits & OpenGl_PO_TextureEnv) != 0)
{
@@ -1571,7 +1574,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
EOL" TexCoord = vec4(aReflect.xy * inversesqrt (dot (aReflect, aReflect)) * 0.5 + vec2 (0.5), 0.0, 1.0);";
aSrcFragGetColor =
EOL"vec4 getColor(void) { return occTexture2D (occSamplerBaseColor, TexCoord.st); }";
EOL"vec4 getColor(void) { return occTexture2D (occActiveSampler, TexCoord.st); }";
}
}
if ((theBits & OpenGl_PO_VertColor) != 0)
@@ -1752,7 +1755,7 @@ TCollection_AsciiString OpenGl_ShaderManager::pointSpriteShadingSrc (const TColl
EOL"vec4 getColor(void)"
EOL"{"
EOL" vec4 aColor = " + theBaseColorSrc + ";"
EOL" aColor = occTexture2D(occSamplerBaseColor, " THE_VEC2_glPointCoord ") * aColor;"
EOL" aColor = occTexture2D(occActiveSampler, " THE_VEC2_glPointCoord ") * aColor;"
EOL" if (aColor.a <= 0.1) discard;"
EOL" return aColor;"
EOL"}";
@@ -1939,7 +1942,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S
EOL"vec4 getColor(void)"
EOL"{"
EOL" vec4 aColor = gl_FrontFacing ? FrontColor : BackColor;"
EOL" return occTexture2D(occSamplerBaseColor, TexCoord.st / TexCoord.w) * aColor;"
EOL" return occTexture2D(occActiveSampler, TexCoord.st / TexCoord.w) * aColor;"
EOL"}";
}
}
@@ -2109,7 +2112,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
EOL"vec4 getColor(void)"
EOL"{"
EOL" vec4 aColor = " thePhongCompLight ";"
EOL" return occTexture2D(occSamplerBaseColor, TexCoord.st / TexCoord.w) * aColor;"
EOL" return occTexture2D(occActiveSampler, TexCoord.st / TexCoord.w) * aColor;"
EOL"}";
}
}

View File

@@ -39,6 +39,7 @@
#include <StepBasic_ProductDefinition.hxx>
#include <StepBasic_ProductDefinitionFormation.hxx>
#include <StepBasic_ProductDefinitionRelationship.hxx>
#include <StepBasic_ProductDefinitionWithAssociatedDocuments.hxx>
#include <StepBasic_SiUnit.hxx>
#include <StepBasic_SiUnitAndLengthUnit.hxx>
#include <StepBasic_Unit.hxx>
@@ -1131,6 +1132,7 @@ Standard_Boolean STEPCAFControl_Reader::ReadNames (const Handle(XSControl_WorkSe
Standard_Integer nb = Model->NbEntities();
Handle(Standard_Type) tNAUO = STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence);
Handle(Standard_Type) tPD = STANDARD_TYPE(StepBasic_ProductDefinition);
Handle(Standard_Type) tPDWAD = STANDARD_TYPE(StepBasic_ProductDefinitionWithAssociatedDocuments);
Handle(TCollection_HAsciiString) name;
TDF_Label L;
for (Standard_Integer i = 1; i <= nb; i++) {
@@ -1163,7 +1165,7 @@ Standard_Boolean STEPCAFControl_Reader::ReadNames (const Handle(XSControl_WorkSe
}
// for PD get name of associated product
if ( enti->DynamicType() == tPD ) {
if (enti->DynamicType() == tPD || enti->DynamicType() == tPDWAD) {
L.Nullify();
Handle(StepBasic_ProductDefinition) PD =
Handle(StepBasic_ProductDefinition)::DownCast(enti);

View File

@@ -281,6 +281,7 @@ namespace
static Standard_Boolean shadeFromShape (const TopoDS_Shape& theShape,
const Handle(Prs3d_Presentation)& thePrs,
const Handle(Prs3d_Drawer)& theDrawer,
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle,
const Standard_Boolean theHasTexels,
const gp_Pnt2d& theUVOrigin,
const gp_Pnt2d& theUVRepeat,
@@ -296,6 +297,9 @@ namespace
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePrs);
aGroup->SetClosed (theIsClosed);
aGroup->SetGroupPrimitivesAspect (theDrawer->ShadingAspect()->Aspect());
if (!theCappingStyle.IsNull())
aGroup->SetGroupPrimitivesAspect (theCappingStyle);
aGroup->AddPrimitiveArray (aPArray);
return Standard_True;
}
@@ -500,11 +504,12 @@ void StdPrs_ShadedShape::ExploreSolids (const TopoDS_Shape& theShape,
void StdPrs_ShadedShape::Add (const Handle(Prs3d_Presentation)& thePrs,
const TopoDS_Shape& theShape,
const Handle(Prs3d_Drawer)& theDrawer,
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle,
const StdPrs_Volume theVolume)
{
gp_Pnt2d aDummy;
StdPrs_ShadedShape::Add (thePrs, theShape, theDrawer,
Standard_False, aDummy, aDummy, aDummy, theVolume);
Standard_False, aDummy, aDummy, aDummy, theCappingStyle, theVolume);
}
// =======================================================================
@@ -518,6 +523,7 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
const gp_Pnt2d& theUVOrigin,
const gp_Pnt2d& theUVRepeat,
const gp_Pnt2d& theUVScale,
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle,
const StdPrs_Volume theVolume)
{
if (theShape.IsNull())
@@ -555,20 +561,20 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
if (aClosed.NbChildren() > 0)
{
shadeFromShape (aClosed, thePrs, theDrawer,
shadeFromShape (aClosed, thePrs, theDrawer, theCappingStyle,
theHasTexels, theUVOrigin, theUVRepeat, theUVScale, true);
}
if (anOpened.NbChildren() > 0)
{
shadeFromShape (anOpened, thePrs, theDrawer,
shadeFromShape (anOpened, thePrs, theDrawer, theCappingStyle,
theHasTexels, theUVOrigin, theUVRepeat, theUVScale, false);
}
}
else
{
// if the shape type is not compound, composolid or solid, use autodetection back-facing filled
shadeFromShape (theShape, thePrs, theDrawer,
shadeFromShape (theShape, thePrs, theDrawer, theCappingStyle,
theHasTexels, theUVOrigin, theUVRepeat, theUVScale,
theVolume == StdPrs_Volume_Closed);
}

View File

@@ -43,13 +43,25 @@ public:
//! @param theVolumeType defines the way how to interpret input shapes - as Closed volumes (to activate back-face
//! culling and capping plane algorithms), as Open volumes (shells or solids with holes)
//! or to perform Autodetection (would split input shape into two groups)
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation, const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer, const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation,
const TopoDS_Shape& theShape,
const Handle(Prs3d_Drawer)& theDrawer,
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle = Handle(Graphic3d_AspectFillCapping)(),
StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
//! Shades <theShape> with texture coordinates.
//! @param theVolumeType defines the way how to interpret input shapes - as Closed volumes (to activate back-face
//! culling and capping plane algorithms), as Open volumes (shells or solids with holes)
//! or to perform Autodetection (would split input shape into two groups)
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation, const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer, const Standard_Boolean theHasTexels, const gp_Pnt2d& theUVOrigin, const gp_Pnt2d& theUVRepeat, const gp_Pnt2d& theUVScale, const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation,
const TopoDS_Shape& theShape,
const Handle(Prs3d_Drawer)& theDrawer,
const Standard_Boolean theHasTexels,
const gp_Pnt2d& theUVOrigin,
const gp_Pnt2d& theUVRepeat,
const gp_Pnt2d& theUVScale,
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle = Handle(Graphic3d_AspectFillCapping)(),
const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
//! Searches closed and unclosed subshapes in shape structure and puts them
//! into two compounds for separate processing of closed and unclosed sub-shapes

View File

@@ -26,6 +26,7 @@
#include <AIS_InteractiveObject.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_ViewCube.hxx>
#include <Aspect_Grid.hxx>
#include <DBRep.hxx>
#include <Draw_ProgressIndicator.hxx>
@@ -286,6 +287,25 @@ Standard_EXPORT Handle(AIS_Manipulator) GetActiveAISManipulator()
return NULL;
}
typedef NCollection_DataMap<Handle(V3d_View), Handle(AIS_ViewCube)> ViewerTest_MapOfViewCube;
Standard_EXPORT ViewerTest_MapOfViewCube& MapOfViewCube()
{
static ViewerTest_MapOfViewCube aViewMap;
return aViewMap;
}
Standard_EXPORT Handle(AIS_ViewCube) ActiveViewCube()
{
Handle(AIS_ViewCube) aCube;
if (MapOfViewCube().Find (ViewerTest::CurrentView(), aCube))
{
return aCube;
}
return NULL;
}
//==============================================================================
#ifdef _WIN32
@@ -8474,7 +8494,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
aClipPlane->SetUseObjectMaterial (toEnable == Standard_True);
aClipPlane->CappingSectionStyle()->SetUseObjectMaterial (toEnable == Standard_True);
anArgIter += 1;
}
}
@@ -8491,7 +8511,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
aClipPlane->SetUseObjectTexture (toEnable == Standard_True);
aClipPlane->CappingSectionStyle()->SetUseObjectTexture (toEnable == Standard_True);
anArgIter += 1;
}
}
@@ -8506,7 +8526,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
aClipPlane->SetUseObjectShader (toEnable == Standard_True);
aClipPlane->CappingSectionStyle()->SetUseObjectShader (toEnable == Standard_True);
anArgIter += 1;
}
}
@@ -8523,10 +8543,10 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
return 1;
}
Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial();
Graphic3d_MaterialAspect aMat = aClipPlane->CappingSectionStyle()->Material();
aMat.SetAmbientColor (aColor);
aMat.SetDiffuseColor (aColor);
aClipPlane->SetCappingMaterial (aMat);
aClipPlane->CappingSectionStyle()->SetMaterial (aMat);
anArgIter += aNbParsed;
}
else if ((aChangeArg == "-transparency"
@@ -8534,44 +8554,34 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
&& aNbChangeArgs >= 2)
{
TCollection_AsciiString aValStr (aChangeArgs[1]);
Handle(Graphic3d_AspectFillArea3d) anAspect = aClipPlane->CappingAspect();
if (aValStr.IsRealValue())
{
Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial();
Graphic3d_MaterialAspect aMat = aClipPlane->CappingSectionStyle()->Material();
aMat.SetTransparency ((float )aValStr.RealValue());
anAspect->SetAlphaMode (Graphic3d_AlphaMode_BlendAuto);
aClipPlane->SetCappingMaterial (aMat);
aClipPlane->CappingSectionStyle()->SetMaterial (aMat);
}
else
{
aValStr.LowerCase();
Graphic3d_AlphaMode aMode = Graphic3d_AlphaMode_BlendAuto;
if (aValStr == "opaque")
{
aMode = Graphic3d_AlphaMode_Opaque;
}
else if (aValStr == "mask")
{
aMode = Graphic3d_AlphaMode_Mask;
}
else if (aValStr == "blend")
{
aMode = Graphic3d_AlphaMode_Blend;
}
else if (aValStr == "blendauto")
{
aMode = Graphic3d_AlphaMode_BlendAuto;
}
else
{
std::cout << "Syntax error at '" << aValStr << "'\n";
return 1;
}
anAspect->SetAlphaMode (aMode);
aClipPlane->SetCappingAspect (anAspect);
std::cout << "Syntax error at '" << aValStr << "'\n";
return 1;
}
anArgIter += 1;
}
else if (aChangeArg == "-overrideaspect"
|| aChangeArg == "overrideaspect")
{
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
aClipPlane->SetToOverrideCappingAspect (toEnable == Standard_True);
anArgIter += 1;
}
}
else if (aChangeArg == "-texname"
|| aChangeArg == "texname")
{
@@ -8585,20 +8595,22 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
if (!aTexture->IsDone())
{
aClipPlane->SetCappingTexture (NULL);
aClipPlane->CappingSectionStyle()->SetTexture (Handle(Graphic3d_TextureMap)());
}
else
{
aTexture->EnableModulate();
aTexture->EnableRepeat();
aClipPlane->SetCappingTexture (aTexture);
aClipPlane->CappingSectionStyle()->SetTexture (aTexture.get());
}
anArgIter += 1;
}
else if (aChangeArg == "-texscale"
|| aChangeArg == "texscale")
{
if (aClipPlane->CappingTexture().IsNull())
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->Texture();
if (aHatchTexture.IsNull())
{
std::cout << "Error: no texture is set.\n";
return 1;
@@ -8612,13 +8624,15 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
aClipPlane->CappingTexture()->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
aHatchTexture->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
anArgIter += 2;
}
else if (aChangeArg == "-texorigin"
|| aChangeArg == "texorigin") // texture origin
{
if (aClipPlane->CappingTexture().IsNull())
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->Texture();
if (aHatchTexture.IsNull())
{
std::cout << "Error: no texture is set.\n";
return 1;
@@ -8633,13 +8647,15 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
aClipPlane->CappingTexture()->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
aHatchTexture->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
anArgIter += 2;
}
else if (aChangeArg == "-texrotate"
|| aChangeArg == "texrotate") // texture rotation
{
if (aClipPlane->CappingTexture().IsNull())
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->Texture();
if (aHatchTexture.IsNull())
{
std::cout << "Error: no texture is set.\n";
return 1;
@@ -8652,7 +8668,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
}
Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
aClipPlane->CappingTexture()->GetParams()->SetRotation (aRot);
aHatchTexture->GetParams()->SetRotation (aRot);
anArgIter += 1;
}
else if (aChangeArg == "-hatch"
@@ -8664,22 +8680,165 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
return 1;
}
TCollection_AsciiString aHatchStr (aChangeArgs[1]);
aHatchStr.LowerCase();
if (aHatchStr == "on")
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
aClipPlane->SetCappingHatchOn();
aClipPlane->CappingSectionStyle()->SetToDrawHatch (toEnable == Standard_True);
anArgIter += 1;
}
else if (aHatchStr == "off")
}
else if (aChangeArg == "-hatchtexture"
|| aChangeArg == "hatchtexture")
{
if (aNbChangeArgs < 2)
{
aClipPlane->SetCappingHatchOff();
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
TCollection_AsciiString aTextureName (aChangeArgs[1]);
Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
if (!aTexture->IsDone())
{
aClipPlane->CappingSectionStyle()->SetHatchStyle (Handle(Graphic3d_TextureMap)());
}
else
{
aClipPlane->SetCappingHatch ((Aspect_HatchStyle)Draw::Atoi (aChangeArgs[1]));
aTexture->EnableModulate();
aTexture->EnableRepeat();
aClipPlane->CappingSectionStyle()->SetHatchStyle (aTexture.get());
aClipPlane->CappingSectionStyle()->SetToDrawHatch (true);
}
anArgIter += 1;
}
else if (aChangeArg == "-hatchstipple"
|| aChangeArg == "hatchstipple")
{
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
aClipPlane->CappingSectionStyle()->SetHatchStyle ((Aspect_HatchStyle)Draw::Atoi (aChangeArgs[1]));
aClipPlane->CappingSectionStyle()->SetToDrawHatch (true);
anArgIter += 1;
}
else if (aChangeArg == "-hatchcolor"
|| aChangeArg == "hatchcolor")
{
Quantity_Color aColor;
Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1,
aChangeArgs + 1,
aColor);
if (aNbParsed == 0)
{
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
Graphic3d_MaterialAspect aMat = aClipPlane->CappingSectionStyle()->HatchMaterial();
aMat.SetAmbientColor (aColor);
aMat.SetDiffuseColor (aColor);
aClipPlane->CappingSectionStyle()->SetHatchMaterial (aMat);
anArgIter += aNbParsed;
}
else if (aChangeArg == "-hatchscale"
|| aChangeArg == "hatchscale")
{
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->TextureHatch();
if (aHatchTexture.IsNull())
{
std::cout << "Error: no texture is set.\n";
return 1;
}
if (aNbChangeArgs < 3)
{
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
aHatchTexture->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
anArgIter += 2;
}
else if (aChangeArg == "-hatchorigin"
|| aChangeArg == "hatchorigin") // texture origin
{
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->TextureHatch();
if (aHatchTexture.IsNull())
{
std::cout << "Error: no texture is set.\n";
return 1;
}
if (aNbChangeArgs < 3)
{
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
aHatchTexture->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
anArgIter += 2;
}
else if (aChangeArg == "-hatchrotate"
|| aChangeArg == "hatchrotate") // texture rotation
{
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->TextureHatch();
if (aHatchTexture.IsNull())
{
std::cout << "Error: no texture is set.\n";
return 1;
}
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
aHatchTexture->GetParams()->SetRotation (aRot);
anArgIter += 1;
}
else if (aChangeArg == "-hatchzoompers"
|| aChangeArg == "hatchzoompers")
{
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
aClipPlane->CappingSectionStyle()->SetHatchZoomPeristent (toEnable == Standard_True);
anArgIter += 1;
}
}
else if (aChangeArg == "-hatchrotatepers"
|| aChangeArg == "hatchrotatepers")
{
if (aNbChangeArgs < 2)
{
std::cout << "Syntax error: need more arguments.\n";
return 1;
}
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
aClipPlane->CappingSectionStyle()->SetHatchRotationPeristent (toEnable == Standard_True);
anArgIter += 1;
}
}
else if (aChangeArg == "-delete"
|| aChangeArg == "delete")
{
@@ -11859,6 +12018,210 @@ static int VDumpSelectionImage (Draw_Interpretor& /*theDi*/,
return 0;
}
//===============================================================================================
//function : VViewCube
//purpose :
//===============================================================================================
static int VViewCube (Draw_Interpretor& theDi,
Standard_Integer theArgsNb,
const char** theArgVec)
{
if (theArgsNb < 2)
{
std::cout << "Syntax error: wrong number arguments for '" << theArgVec[0] << "'\n";
return 1;
}
const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext();
const Handle(V3d_View)& aView = ViewerTest::CurrentView();
if (aContext.IsNull() || aView.IsNull())
{
std::cout << "Error: no active view.\n";
return 1;
}
ViewerTest_AutoUpdater anUpdateTool (aContext, aView);
Standard_Integer anArgIter = 1;
for (; anArgIter < theArgsNb; ++anArgIter)
{
anUpdateTool.parseRedrawMode (theArgVec[anArgIter]);
}
Handle(AIS_ViewCube) aViewCube;
ViewerTest_CmdParser aCmd;
aCmd.AddDescription ("vviewcube Name [options]. Commmand manages View Cube object:");
aCmd.AddOption ("enable", "enables view cube");
aCmd.AddOption ("disable", "disables view cube");
aCmd.AddOption ("remove", "removes view cube presentation from context and view");
aCmd.AddOption ("remove", "removes view cube presentation from context and view");
aCmd.AddOption ("reset", "reset geomertical and visual attributes");
aCmd.AddOption ("size", "... size - set size of View Cube");
aCmd.AddOption ("adaptsize", " - adapt all another parameters to input size");
aCmd.AddOption ("color", "... r g b - set color of View Cube ");
aCmd.AddOption ("boxcolor", "... r g b - set box color of view cube");
aCmd.AddOption ("arrowcolor", "... r g b - set arrow color of view cube");
aCmd.AddOption ("textcolor", "... r g b - set side text color of view cube");
aCmd.AddOption ("innercolor", "... r g b - set inner box color of view cube");
aCmd.AddOption ("arrowangle", "... value - set pointer angle of arrows in radians");
aCmd.AddOption ("arrowlength", "... value - set length of arrows");
aCmd.AddOption ("arrowpadding", "... value - set padding between axis and arrows");
aCmd.AddOption ("transparency", "... [0;1] - set transparency of object");
aCmd.AddOption ("boxtransparency", "... [0;1] - set transparency of box in View Cube");
aCmd.AddOption ("arrowtransparency", "... [0;1] - set transparency of arrows in View Cube");
aCmd.AddOption ("font", "... string - set font name");
aCmd.AddOption ("boxpadding", "... value - set padding between box sides");
aCmd.AddOption ("axispadding", "... value - set padding between box and arrows");
aCmd.AddOption ("cornerradius", "... value - set radius of side corners in [0;0.5] (0-50% of box side size)");
aCmd.AddOption ("hideedges", " - hide edges of View Cube");
aCmd.AddOption ("showedges", " - show edges of View Cube");
aCmd.AddOption ("hidevertices", " - hide vertices ov View Cube");
aCmd.AddOption ("showvertices", " - show vertices ov View Cube");
aCmd.AddOption ("position", "... PixX PixY - 2D position of View Cube from top left corner");
aCmd.Parse (theArgsNb, theArgVec);
if (aCmd.HasOption ("help"))
{
theDi.PrintHelp (theArgVec[0]);
return 0;
}
// Get current view cube entity
aViewCube = ActiveViewCube();
if (aViewCube.IsNull())
{
aViewCube = new AIS_ViewCube();
MapOfViewCube().Bind (aView, aViewCube);
aViewCube->SetAutoTransform (Standard_True);
}
if (aCmd.HasOption ("color"))
{
aViewCube->SetColor (Quantity_Color (aCmd.ArgVec3f ("color")));
}
if (aCmd.HasOption ("boxcolor"))
{
aViewCube->SetBoxColor (Quantity_Color (aCmd.ArgVec3f ("boxcolor")));
}
if (aCmd.HasOption ("arrowcolor"))
{
aViewCube->SetArrowColor (Quantity_Color (aCmd.ArgVec3f ("arrowcolor")));
}
if (aCmd.HasOption ("textcolor"))
{
aViewCube->SetTextColor (Quantity_Color (aCmd.ArgVec3f ("textcolor")));
}
if (aCmd.HasOption ("innercolor"))
{
aViewCube->SetInnerColor (Quantity_Color (aCmd.ArgVec3f ("innercolor")));
}
if (aCmd.HasOption ("arrowangle"))
{
aViewCube->SetArrowAngle (aCmd.ArgDouble ("arrowangle") * M_PI / 180.0);
}
if (aCmd.HasOption ("arrowlength"))
{
aViewCube->SetArrowLength (aCmd.ArgDouble ("arrowlength"));
}
if (aCmd.HasOption ("arrowpadding"))
{
aViewCube->SetArrowPadding (aCmd.ArgDouble ("arrowpadding"));
}
if (aCmd.HasOption ("transparency"))
{
aViewCube->SetTransparency (aCmd.ArgDouble ("transparency"));
}
if (aCmd.HasOption ("boxtransparency"))
{
aViewCube->SetBoxTransparency (aCmd.ArgDouble ("boxtransparency"));
}
if (aCmd.HasOption ("arrowtransparency"))
{
aViewCube->SetArrowTransparency (aCmd.ArgDouble ("arrowtransparency"));
}
if (aCmd.HasOption ("font"))
{
aViewCube->SetFont (aCmd.Arg ("font", 0).c_str());
}
if (aCmd.HasOption ("boxpadding"))
{
aViewCube->SetBoxPadding (aCmd.ArgDouble ("boxpadding"));
}
if (aCmd.HasOption ("axispadding"))
{
aViewCube->SetAxisPadding (aCmd.ArgDouble ("axispadding"));
}
if (aCmd.HasOption ("cornerradius"))
{
aViewCube->SetCornerRadius (aCmd.ArgDouble ("cornerradius"));
}
if (aCmd.HasOption ("hideedges"))
{
aViewCube->SetDrawEdges (Standard_False);
}
if (aCmd.HasOption ("showedges"))
{
aViewCube->SetDrawEdges (Standard_True);
}
if (aCmd.HasOption ("hidevertices"))
{
aViewCube->SetDrawVertices (Standard_False);
}
if (aCmd.HasOption ("showvertices"))
{
aViewCube->SetDrawVertices (Standard_True);
}
if (aCmd.HasOption ("position", 2))
{
aViewCube->SetPosition (Graphic3d_Vec2i (aCmd.ArgInt ("position", 0), aCmd.ArgInt ("position", 1)),
aView);
}
if (aCmd.HasOption ("size"))
{
aViewCube->SetSize (aCmd.ArgDouble ("size", 0), aCmd.HasOption ("adaptsize"));
}
if (aCmd.HasOption ("reset"))
{
aViewCube->Reset();
}
// Enable View Cube for current view
if (aCmd.HasOption ("enable") && !aContext->IsDisplayed (aViewCube))
{
aContext->MainSelector()->SetPickClosest (Standard_False);
if (aViewCube->View().IsNull())
{
aViewCube->SetView (aView);
aViewCube->AddTo (aContext, aView);
}
else
{
aViewCube->Show();
}
}
else if (aCmd.HasOption ("disable") && aContext->IsDisplayed (aViewCube))
{
ViewerTest::GetAISContext()->MainSelector()->SetPickClosest (Standard_True);
aViewCube->Hide();
}
else if (aCmd.HasOption ("remove") && aContext->IsDisplayed (aViewCube))
{
ViewerTest::GetAISContext()->MainSelector()->SetPickClosest (Standard_True);
MapOfViewCube().UnBind (aViewCube->View());
aContext->Remove (aViewCube, Standard_False);
}
else
{
TColStd_ListOfInteger aModes;
aViewCube->ToBeUpdated (aModes);
if (!aModes.IsEmpty())
{
aContext->Redisplay (aViewCube, Standard_False);
}
}
return 0;
}
//=======================================================================
//function : ViewerCommands
//purpose :
@@ -12387,6 +12750,16 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
"\n\t\t: [-color R G B] [-transparency Value] [-hatch {on|off|ID}]"
"\n\t\t: [-texName Texture] [-texScale SX SY] [-texOrigin TX TY]"
"\n\t\t: [-texRotate Angle]"
/*"\n\t\t: [-overrideAspect {0|1}]"
"\n\t\t: [-color R G B]"
"\n\t\t: [-texture Texture] [-texScale SX SY]"
"\n\t\t: [-texOrigin TX TY] [-texRotate Angle]"
"\n\t\t: [-hatch {on|off}] [-hatchStipple mask]"
"\n\t\t: [-hatchColor R G B] [-hatchTexture texture]"
"\n\t\t: [-hatchScale SX SY] [-hatchOrigin TX TY]"
"\n\t\t: [-hatchRotate Angle]"
"\n\t\t: [-hatchZoomPers {0|1}]"
"\n\t\t: [-hatchRotatePers {0|1}]"*/
"\n\t\t: [-useObjMaterial {0|1}] [-useObjTexture {0|1}]"
"\n\t\t: [-useObjShader {0|1}]"
"\n\t\t: Clipping planes management:"
@@ -12399,13 +12772,22 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
"\n\t\t: -clone SourcePlane NewPlane clone the plane definition."
"\n\t\t: Capping options:"
"\n\t\t: -capping {off|on|0|1} turn capping on/off"
"\n\t\t: -overrideAspect override presentation aspect (if defined)"
"\n\t\t: -color R G B set capping color"
"\n\t\t: -transparency Value set capping transparency 0..1"
"\n\t\t: -texName Texture set capping texture"
"\n\t\t: -texScale SX SY set capping tex scale"
"\n\t\t: -texOrigin TX TY set capping tex origin"
"\n\t\t: -texRotate Angle set capping tex rotation"
"\n\t\t: -hatch {on|off|ID} set capping hatching mask"
"\n\t\t: -hatch {on|off} turn on/off hatch style on capping"
"\n\t\t: -hatchStipple ID set stipple mask for drawing hatch"
"\n\t\t: -hatchColor R G B set color for hatch material"
"\n\t\t: -hatchTexture Texture set texture (semi-opaque) for drawing hatch"
"\n\t\t: -hatchScale SX SY set hatch texture scale"
"\n\t\t: -hatchOrigin TX TY set hatch texture origin"
"\n\t\t: -hatchRotate Angle set hatch texture rotation"
"\n\t\t: -hatchZoomPers allow hatch tetxure mapping to be constant when zooming"
"\n\t\t: -hatchRotatePers allow hatch tetxure mapping to be constant when rotating"
"\n\t\t: -useObjMaterial {off|on|0|1} use material of clipped object"
"\n\t\t: -useObjTexture {off|on|0|1} use texture of clipped object"
"\n\t\t: -useObjShader {off|on|0|1} use shader program of object",
@@ -12557,4 +12939,38 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
"vprogressive",
__FILE__, VProgressiveMode, group);
#endif
theCommands.Add ("vviewcube",
"\n vviewcube [-enable|-disable]"
"\n Warning: after end pf test please call vviewcube -remove, otherwise View Cube will hold down active view from closing"
"\n tool to create and manage interactive view manipualtion object for active view."
"\n Options: "
"\n '-enable|disable' display/erase view cube with defined visual options"
"\n '-reset reset geomertical and visual attributes'"
"\n '-size Value' adjust position when attaching"
"\n '-adaptSize' call with -size to adapt all part to size of 3D box"
"\n 'remove' removes view cube presentation from context and view"
"\n 'size Size' set size of View Cube"
"\n 'color R G B' set color of View Cube in limits [0;1]"
"\n 'boxcolor R G B' set box color of view cube in limits [0;1]"
"\n 'arrowcolor R G B' set arrow color of view cube in limits [0;1]"
"\n 'textcolor R G B' set color of side text of view cube in limits [0;1]"
"\n 'innercolor R G B' set inner box color of view cube in limits [0;1]"
"\n 'arrowangle Value' set pointer angle of arrows in radians"
"\n 'arrowlength Value' set length of arrows"
"\n 'arrowpadding Value' set padding between axis and arrows"
"\n 'transparency [0;1]' set transparency of object"
"\n 'boxtransparency [0;1]' set transparency of box in View Cube"
"\n 'arrowtransparency [0;1]' set transparency of arrows in View Cube"
"\n 'font Name' set font name"
"\n 'boxpadding Value' set padding between box sides"
"\n 'axispadding Value' set padding between box and arrows"
"\n 'cornerradius Value' set radius of corners of sides"
"\n 'hideedges' hide edges of View Cube"
"\n 'showedges' show edges of View Cube"
"\n 'hidevertices' hide vertices ov View Cube"
"\n 'showvertices' show vertices ov View Cube"
"\n 'position XPix YPix' 2D position of View Cube from top left corner",
__FILE__, VViewCube, group);
}

View File

@@ -65,3 +65,8 @@ XCAFDoc_ViewTool.cxx
XCAFDoc_ViewTool.hxx
XCAFDoc_Volume.cxx
XCAFDoc_Volume.hxx
XCAFDoc_Animation.cxx
XCAFDoc_Animation.hxx
XCAFDoc_AnimationTool.cxx
XCAFDoc_AnimationTool.hxx

View File

@@ -263,13 +263,24 @@ Standard_GUID XCAFDoc::ViewRefPlaneGUID()
}
//=======================================================================
//function : ViewRefPlaneGUID
//function : ViewRefNoteGUID
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ViewRefNoteGUID()
{
static Standard_GUID ID("C814ACC6-43AC-4812-9B2A-4E9A2A549354");
static Standard_GUID ID("efd213e2-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
//=======================================================================
//function : ViewRefEnabledShapesGUID
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ViewRefEnabledShapesGUID()
{
static Standard_GUID ID("efd213e4-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
@@ -294,3 +305,23 @@ Standard_GUID XCAFDoc::LockGUID()
static Standard_GUID ID("efd213eb-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
//=======================================================================
//function : ViewRefEnabledShapesGUID
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ClipPlaneCappingRefGUID()
{
static Standard_GUID ID("50976BC9-A2B0-497C-9A66-443FB8703DAD");
return ID;
}
//=======================================================================
//function : LockGUID
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::ClipPlaneVisibleRefGUID()
{
static Standard_GUID ID("279E76D5-4EFF-4F48-81D5-01CA307A5634");
return ID;
}

View File

@@ -122,9 +122,20 @@ public:
//! Return GUIDs for TreeNode representing specified types of View
Standard_EXPORT static Standard_GUID ViewRefPlaneGUID();
//! Return GUIDs for GraphNode representing specified types of View
//! Return GUIDs for TreeNode representing specified types of View
Standard_EXPORT static Standard_GUID ViewRefNoteGUID();
//! Return GUIDs for TreeNode representing specified types of View
Standard_EXPORT static Standard_GUID ViewRefEnabledShapesGUID();
//! Return GUIDs for clipping plane capping
Standard_EXPORT static Standard_GUID ClipPlaneCappingRefGUID();
//! Return GUIDs for clipping plane visibility
Standard_EXPORT static Standard_GUID ClipPlaneVisibleRefGUID();
//! Return GUIDs for GraphNode representing specified types of View
Standard_EXPORT static Standard_GUID ViewRefAnnotationGUID();
//! Returns GUID for UAttribute identifying lock flag

View File

@@ -0,0 +1,214 @@
// Created on: 2017-10-02
// Created by: Elena MOZOKHINA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Standard_GUID.hxx>
#include <Standard_Type.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_Label.hxx>
#include <TDF_RelocationTable.hxx>
#include <XCAFDoc_Animation.hxx>
#include <TColStd_HArray1OfByte.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_Animation, TDF_Attribute)
//=======================================================================
//function : XCAFDoc_Animation
//purpose :
//=======================================================================
XCAFDoc_Animation::XCAFDoc_Animation()
{
}
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& XCAFDoc_Animation::GetID()
{
static Standard_GUID MatID("431A3BB7-7113-45C4-8653-AED7CC0012E1");
return MatID;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(XCAFDoc_Animation) XCAFDoc_Animation::Set(const TDF_Label& theLabel,
const Handle(TCollection_HAsciiString)& theName,
const Handle(TColStd_HArray1OfByte)& theImage,
const Handle(TColStd_HArray1OfByte)& theAnimation)
{
Handle(XCAFDoc_Animation) A;
if (!theLabel.FindAttribute(XCAFDoc_Animation::GetID(), A))
{
A = new XCAFDoc_Animation();
theLabel.AddAttribute(A);
}
A->Set(theName, theImage, theAnimation);
return A;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(XCAFDoc_Animation) XCAFDoc_Animation::Set(const TDF_Label& theLabel,
const Handle(TCollection_HAsciiString)& theName,
OSD_File& theImageFile, OSD_File& theAnimationFile)
{
Handle(XCAFDoc_Animation) anAnimation;
if (!theLabel.FindAttribute(XCAFDoc_Animation::GetID(), anAnimation))
{
anAnimation = new XCAFDoc_Animation();
if (anAnimation->Set(theName, theImageFile, theAnimationFile))
theLabel.AddAttribute(anAnimation);
else
anAnimation.Nullify();
}
else
anAnimation->Set(theName, theImageFile, theAnimationFile);
return anAnimation;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_Animation::Set(const Handle(TCollection_HAsciiString)& theName, OSD_File& theImageFile, OSD_File& theAnimationFile)
{
if (!theImageFile.IsOpen() || !theImageFile.IsReadable() || !theAnimationFile.IsOpen() || !theAnimationFile.IsReadable())
return Standard_False;
if (theImageFile.Size() > (Standard_Size)IntegerLast() || theAnimationFile.Size() > (Standard_Size)IntegerLast())
return Standard_False;
myImage.reset(new TColStd_HArray1OfByte(1, static_cast<Standard_Integer>(theImageFile.Size())));
Standard_Integer nbReadBytes = 0;
theImageFile.Read((Standard_Address)&myImage->First(), myImage->Length(), nbReadBytes);
if (nbReadBytes < myImage->Length())
return Standard_False;
myAnimation.reset(new TColStd_HArray1OfByte(1, static_cast<Standard_Integer>(theAnimationFile.Size())));
nbReadBytes = 0;
theAnimationFile.Read((Standard_Address)&myAnimation->First(), myAnimation->Length(), nbReadBytes);
if (nbReadBytes < myAnimation->Length())
return Standard_False;
myName = theName;
return Standard_True;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
void XCAFDoc_Animation::Set(const Handle(TCollection_HAsciiString)& theName,
const Handle(TColStd_HArray1OfByte)& theImage,
const Handle(TColStd_HArray1OfByte)& theAnimation)
{
myName = theName;
myImage = theImage;
myAnimation = theAnimation;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
void XCAFDoc_Animation::Set(const Handle(TCollection_HAsciiString)& theName)
{
myName = theName;
}
//=======================================================================
//function : GetName
//purpose :
//=======================================================================
Handle(TCollection_HAsciiString) XCAFDoc_Animation::GetName() const
{
return myName;
}
//=======================================================================
//function : GetImage
//purpose :
//=======================================================================
Handle(TColStd_HArray1OfByte) XCAFDoc_Animation::GetImage() const
{
return myImage;
}
//=======================================================================
//function : GetAnimation
//purpose :
//=======================================================================
Handle(TColStd_HArray1OfByte) XCAFDoc_Animation::GetAnimation() const
{
return myAnimation;
}
//=======================================================================
//function : ID
//purpose :
//=======================================================================
const Standard_GUID& XCAFDoc_Animation::ID() const
{
return GetID();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void XCAFDoc_Animation::Restore(const Handle(TDF_Attribute)& With)
{
myName = Handle(XCAFDoc_Animation)::DownCast(With)->GetName();
myImage = Handle(XCAFDoc_Animation)::DownCast(With)->GetImage();
myAnimation = Handle(XCAFDoc_Animation)::DownCast(With)->GetAnimation();
}
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) XCAFDoc_Animation::NewEmpty() const
{
return new XCAFDoc_Animation();
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void XCAFDoc_Animation::Paste(const Handle(TDF_Attribute)& Into,
const Handle(TDF_RelocationTable)& /*RT*/) const
{
Handle(XCAFDoc_Animation)::DownCast(Into)->Set(myName, myImage, myAnimation);
}

View File

@@ -0,0 +1,82 @@
// Created on: 2017-10-02
// Created by: Elena MOZOKHINA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _XCAFDoc_Animation_HeaderFile
#define _XCAFDoc_Animation_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <OSD_File.hxx>
#include <TDF_Attribute.hxx>
class Standard_GUID;
class TDF_Label;
class TDF_Attribute;
class TDF_RelocationTable;
class XCAFView_Object;
class XCAFDoc_Animation;
class TCollection_HAsciiString;
class TColStd_HArray1OfByte;
DEFINE_STANDARD_HANDLE(XCAFDoc_Animation, TDF_Attribute)
//! attribute to store animation
class XCAFDoc_Animation : public TDF_Attribute
{
public:
Standard_EXPORT XCAFDoc_Animation();
Standard_EXPORT static const Standard_GUID& GetID();
Standard_EXPORT static Handle(XCAFDoc_Animation) Set(const TDF_Label& label, const Handle(TCollection_HAsciiString)& theName, const Handle(TColStd_HArray1OfByte)& theImage, const Handle(TColStd_HArray1OfByte)& theAnimation);
Standard_EXPORT static Handle(XCAFDoc_Animation) Set(const TDF_Label& theLabel, const Handle(TCollection_HAsciiString)& theName, OSD_File& theImageFile, OSD_File& theAnimationFile);
Standard_EXPORT void Set(const Handle(TCollection_HAsciiString)& theName, const Handle(TColStd_HArray1OfByte)& theImage, const Handle(TColStd_HArray1OfByte)& theAnimation);
Standard_EXPORT Standard_Boolean Set(const Handle(TCollection_HAsciiString)& aName, OSD_File& theImageFile, OSD_File& theAnimationFile);
Standard_EXPORT void Set(const Handle(TCollection_HAsciiString)& theName);
Standard_EXPORT Handle(TCollection_HAsciiString) GetName() const;
Standard_EXPORT Handle(TColStd_HArray1OfByte) GetImage() const;
Standard_EXPORT Handle(TColStd_HArray1OfByte) GetAnimation() const;
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
Standard_EXPORT void Restore(const Handle(TDF_Attribute)& With) Standard_OVERRIDE;
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT void Paste(const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(XCAFDoc_Animation, TDF_Attribute)
private:
Handle(TCollection_HAsciiString) myName;
Handle(TColStd_HArray1OfByte) myImage;
Handle(TColStd_HArray1OfByte) myAnimation;
};
#endif

View File

@@ -0,0 +1,236 @@
// Created on: 2017-10-02
// Created by: Elena MOZOKHINA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <TCollection_HAsciiString.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_Name.hxx>
#include <TDataStd_TreeNode.hxx>
#include <TDataXtd_Geometry.hxx>
#include <TDataXtd_Plane.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_ChildIDIterator.hxx>
#include <XCAFDoc.hxx>
#include <XCAFDoc_Animation.hxx>
#include <XCAFDoc_AnimationTool.hxx>
#include <TDF_AttributeIterator.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_AnimationTool, TDF_Attribute)
//=======================================================================
//function : BaseLabel
//purpose :
//=======================================================================
TDF_Label XCAFDoc_AnimationTool::BaseLabel() const
{
return Label();
}
//=======================================================================
//function : IsAnimation
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_AnimationTool::IsAnimation(const TDF_Label& theLabel) const
{
if (theLabel.Father() != Label())
return Standard_False;
Handle(XCAFDoc_Animation) anAnimAttribute;
if (!theLabel.FindAttribute(XCAFDoc_Animation::GetID(), anAnimAttribute))
return Standard_False;
return Standard_True;
}
//=======================================================================
//function : GetAnimation
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_AnimationTool::GetAnimation(const TDF_Label& theLabel,
Handle(TCollection_HAsciiString)& theName,
Handle(TColStd_HArray1OfByte)& theImage,
Handle(TColStd_HArray1OfByte)& theAnimation) const
{
if (theLabel.Father() != Label())
return Standard_False;
Handle(XCAFDoc_Animation) animAttr;
if (!theLabel.FindAttribute(XCAFDoc_Animation::GetID(), animAttr)) {
return Standard_False;
}
theName = animAttr->GetName();
theImage = animAttr->GetImage();
theAnimation = animAttr->GetAnimation();
return Standard_True;
}
//=======================================================================
//function : AddAnimation
//purpose :
//=======================================================================
TDF_Label XCAFDoc_AnimationTool::AddAnimation(const Handle(TCollection_HAsciiString)& theName,
const Handle(TColStd_HArray1OfByte)& theImage,
const Handle(TColStd_HArray1OfByte)& theAnimation )
{
TDF_Label animL;
TDF_TagSource aTag;
animL = aTag.NewChild(Label());
XCAFDoc_Animation::Set(animL, theName, theImage, theAnimation);
TDataStd_Name::Set(animL, TCollection_AsciiString(theName->ToCString()));
return animL;
}
//=======================================================================
//function : AddAnimation
//purpose :
//=======================================================================
TDF_Label XCAFDoc_AnimationTool::AddAnimation(const Handle(TCollection_HAsciiString)& theName,
OSD_File& theImageFile, OSD_File& theAnimationFile)
{
TDF_Label animL;
TDF_TagSource aTag;
animL = aTag.NewChild(Label());
TDataStd_Name::Set(animL, TCollection_AsciiString(theName->ToCString()));
XCAFDoc_Animation::Set(animL, theName, theImageFile, theAnimationFile);
return animL;
}
//=======================================================================
//function : RemoveAnimation
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_AnimationTool::RemoveAnimation(const TDF_Label& theLabel) const
{
Handle(XCAFDoc_Animation)anAnimAttr;
if (!IsAnimation(theLabel) || !theLabel.FindAttribute(XCAFDoc_Animation::GetID(), anAnimAttr))
return Standard_False;
theLabel.ForgetAllAttributes(Standard_True);
return Standard_True;
}
//=======================================================================
//function : GetAnimationLabels
//purpose :
//=======================================================================
void XCAFDoc_AnimationTool::GetAnimationLabels(TDF_LabelSequence& theLabels) const
{
theLabels.Clear();
TDF_ChildIterator aChildIterator(Label());
for (; aChildIterator.More(); aChildIterator.Next()) {
TDF_Label aLabel = aChildIterator.Value();
if (IsAnimation(aLabel)) theLabels.Append(aLabel);
}
}
//=======================================================================
//function : SetName
//purpose :
//=======================================================================
void XCAFDoc_AnimationTool::SetName(const TDF_Label& theLabel,
const Handle(TCollection_HAsciiString)& theName) const
{
if (theLabel.Father() != Label())
return;
Handle(XCAFDoc_Animation)anAnimAttr;
if (!theLabel.FindAttribute(XCAFDoc_Animation::GetID(), anAnimAttr))
return;
anAnimAttr->Set(theName);
}
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& XCAFDoc_AnimationTool::GetID()
{
static Standard_GUID AnimationID("7261F539-43AD-4544-8419-AE63C6ED4A41");
return AnimationID;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(XCAFDoc_AnimationTool) XCAFDoc_AnimationTool::Set(const TDF_Label& L)
{
Handle(XCAFDoc_AnimationTool) A;
if (!L.FindAttribute(XCAFDoc_AnimationTool::GetID(), A)) {
A = new XCAFDoc_AnimationTool();
L.AddAttribute(A);
}
return A;
}
//=======================================================================
//function : ID
//purpose :
//=======================================================================
const Standard_GUID& XCAFDoc_AnimationTool::ID() const
{
return GetID();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void XCAFDoc_AnimationTool::Restore(const Handle(TDF_Attribute)& /*with*/)
{
}
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) XCAFDoc_AnimationTool::NewEmpty() const
{
return new XCAFDoc_AnimationTool;
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void XCAFDoc_AnimationTool::Paste(const Handle(TDF_Attribute)& /*into*/,
const Handle(TDF_RelocationTable)& /*RT*/) const
{
}
//=======================================================================
//function : XCAFDoc_AnimationTool
//purpose :
//=======================================================================
XCAFDoc_AnimationTool::XCAFDoc_AnimationTool()
{
}

View File

@@ -0,0 +1,85 @@
// Created on: 2017-10-02
// Created by: Elena MOZOKHINA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _XCAFDoc_AnimationTool_HeaderFile
#define _XCAFDoc_AnimationTool_HeaderFile
#include <TDF_LabelSequence.hxx>
#include <TColStd_HArray1OfByte.hxx>
#include <OSD_File.hxx>
class XCAFDoc_AnimationTool;
DEFINE_STANDARD_HANDLE(XCAFDoc_AnimationToolTool, TDF_Attribute)
//! Provide tool for management of Animations section of document.
//! Provide tool to store, retrieve, remove and modify animations.
//! Each animation has a name and binary data of screenshot and animation.
class XCAFDoc_AnimationTool : public TDF_Attribute
{
public:
Standard_EXPORT XCAFDoc_AnimationTool();
//! Creates (if not exist) Animation tool.
Standard_EXPORT static Handle(XCAFDoc_AnimationTool) Set(const TDF_Label& theLabel);
Standard_EXPORT static const Standard_GUID& GetID();
//! returns the label under which Animations are stored
Standard_EXPORT TDF_Label BaseLabel() const;
//! Returns True if label belongs to a Animations table and
//! is a animation definition
Standard_EXPORT Standard_Boolean IsAnimation (const TDF_Label& theLabel) const;
//! Returns animation defined by label theLabel
//! Returns False if the label is not in Animations table
Standard_EXPORT Standard_Boolean GetAnimation(const TDF_Label& theLabel, Handle(TCollection_HAsciiString)& theName, Handle(TColStd_HArray1OfByte)& theImage, Handle(TColStd_HArray1OfByte)& theAnimation) const;
//! Adds an animation definition to a Animations table
//! Returns created label
Standard_EXPORT TDF_Label AddAnimation(const Handle(TCollection_HAsciiString)& theName, const Handle(TColStd_HArray1OfByte)& theImage, const Handle(TColStd_HArray1OfByte)& theAnimation);
//! Adds an animation definition to a Animations table
//! Returns created label
Standard_EXPORT TDF_Label AddAnimation(const Handle(TCollection_HAsciiString)& theName, OSD_File& theImageFile, OSD_File& theAnimationFile);
//! Removes animation from the Animations table
Standard_EXPORT Standard_Boolean RemoveAnimation(const TDF_Label& theLabel) const;
//! Returns a sequence of animations currently stored
//! in the Animations table
Standard_EXPORT void GetAnimationLabels(TDF_LabelSequence& Labels) const;
//! Rename animation
Standard_EXPORT void SetName(const TDF_Label& theLabelL, const Handle(TCollection_HAsciiString)& theName) const;
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(XCAFDoc_AnimationTool, TDF_Attribute)
};
#endif // _XCAFDoc_ClippingPlaneTool_HeaderFile

View File

@@ -0,0 +1,65 @@
// Created on: 2017-10-02
// Created by: Elena MOZOKHINA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _XCAFDoc_View_HeaderFile
#define _XCAFDoc_View_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
class Standard_GUID;
class TDF_Label;
class TDF_Attribute;
class TDF_RelocationTable;
class XCAFView_Object;
// resolve name collisions with WinAPI headers
#ifdef GetObject
#undef GetObject
#endif
class XCAFDoc_View;
DEFINE_STANDARD_HANDLE(XCAFDoc_View, TDF_Attribute)
//! attribute to store view
class XCAFDoc_View : public TDF_Attribute
{
public:
Standard_EXPORT XCAFDoc_View();
Standard_EXPORT static const Standard_GUID& GetID();
Standard_EXPORT static Handle(XCAFDoc_View) Set (const TDF_Label& theLabel);
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
Standard_EXPORT void Restore (const Handle(TDF_Attribute)& With) Standard_OVERRIDE;
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
Standard_EXPORT void SetObject (const Handle(XCAFView_Object)& theViewObject);
Standard_EXPORT Handle(XCAFView_Object) GetObject() const;
DEFINE_STANDARD_RTTIEXT(XCAFDoc_View, TDF_Attribute)
};
#endif

View File

@@ -59,7 +59,7 @@ Standard_Boolean XCAFDoc_ClippingPlaneTool::IsClippingPlane(const TDF_Label& the
//=======================================================================
Standard_Boolean XCAFDoc_ClippingPlaneTool::GetClippingPlane(const TDF_Label& theLabel,
gp_Pln& thePlane, TCollection_ExtendedString& theName, Standard_Boolean &theCapping) const
gp_Pln& thePlane, TCollection_ExtendedString& theName, Standard_Boolean &theCapping, Standard_Boolean &theVisible) const
{
if (theLabel.Father() != Label())
return Standard_False;
@@ -74,9 +74,13 @@ Standard_Boolean XCAFDoc_ClippingPlaneTool::GetClippingPlane(const TDF_Label& th
theName = aNameAttribute->Get();
Handle(TDataStd_Integer) aCappingAttribute;
if (theLabel.FindAttribute(TDataStd_Integer::GetID(), aCappingAttribute))
if (theLabel.FindAttribute(XCAFDoc::ClipPlaneCappingRefGUID(), aCappingAttribute))
theCapping = (aCappingAttribute->Get() == 1);
Handle(TDataStd_Integer) aVisibleAttribute;
if (theLabel.FindAttribute(XCAFDoc::ClipPlaneVisibleRefGUID(), aVisibleAttribute))
theVisible = (aVisibleAttribute->Get() == 1);
return Standard_True;
}
@@ -86,10 +90,10 @@ Standard_Boolean XCAFDoc_ClippingPlaneTool::GetClippingPlane(const TDF_Label& th
//=======================================================================
Standard_Boolean XCAFDoc_ClippingPlaneTool::GetClippingPlane(const TDF_Label& theLabel,
gp_Pln& thePlane, Handle(TCollection_HAsciiString)& theName, Standard_Boolean &theCapping) const
gp_Pln& thePlane, Handle(TCollection_HAsciiString)& theName, Standard_Boolean &theCapping, Standard_Boolean &theVisible) const
{
TCollection_ExtendedString anExtName;
if (!GetClippingPlane(theLabel, thePlane, anExtName, theCapping))
if (!GetClippingPlane(theLabel, thePlane, anExtName, theCapping, theVisible))
return Standard_False;
theName = new TCollection_HAsciiString(anExtName);
return Standard_True;
@@ -108,8 +112,8 @@ TDF_Label XCAFDoc_ClippingPlaneTool::AddClippingPlane(const gp_Pln thePlane, con
for (Standard_Integer i = 1; i <= aClippingPlanes.Length(); i++) {
gp_Pln aPlane;
TCollection_ExtendedString aName;
Standard_Boolean aCapping;
GetClippingPlane(aClippingPlanes.Value(i), aPlane, aName, aCapping);
Standard_Boolean aCapping, aVisible;
GetClippingPlane(aClippingPlanes.Value(i), aPlane, aName, aCapping, aVisible);
if (!aName.IsEqual(theName))
continue;
if (aPlane.Axis().Angle(thePlane.Axis()) > Precision::Angular())
@@ -149,12 +153,14 @@ TDF_Label XCAFDoc_ClippingPlaneTool::AddClippingPlane(const gp_Pln thePlane, con
//purpose :
//=======================================================================
TDF_Label XCAFDoc_ClippingPlaneTool::AddClippingPlane(const gp_Pln thePlane, const TCollection_ExtendedString theName, const Standard_Boolean theCapping) const
TDF_Label XCAFDoc_ClippingPlaneTool::AddClippingPlane(const gp_Pln thePlane, const TCollection_ExtendedString theName, const Standard_Boolean theCapping, const Standard_Boolean theVisible) const
{
TDF_Label aLabel = AddClippingPlane(thePlane, theName);
Standard_Integer aCappingVal = (theCapping) ? 1 : 0;
TDataStd_Integer::Set(aLabel, aCappingVal);
Standard_Integer aVisibleVal = (theVisible) ? 1 : 0;
TDataStd_Integer::Set(aLabel, aVisibleVal);
return aLabel;
}
@@ -163,10 +169,10 @@ TDF_Label XCAFDoc_ClippingPlaneTool::AddClippingPlane(const gp_Pln thePlane, con
//purpose :
//=======================================================================
TDF_Label XCAFDoc_ClippingPlaneTool::AddClippingPlane(const gp_Pln thePlane, const Handle(TCollection_HAsciiString)& theName, const Standard_Boolean theCapping) const
TDF_Label XCAFDoc_ClippingPlaneTool::AddClippingPlane(const gp_Pln thePlane, const Handle(TCollection_HAsciiString)& theName, const Standard_Boolean theCapping, const Standard_Boolean theVisible) const
{
TCollection_ExtendedString anExtName = TCollection_ExtendedString(theName->String());
return AddClippingPlane(thePlane, anExtName, theCapping);
return AddClippingPlane(thePlane, anExtName, theCapping, theVisible);
}
//=======================================================================
@@ -230,9 +236,9 @@ void XCAFDoc_ClippingPlaneTool::SetCapping(const TDF_Label& theClippingPlaneL, c
if (theClippingPlaneL.Father() != Label())
return;
theClippingPlaneL.ForgetAttribute(TDataStd_Integer::GetID());
theClippingPlaneL.ForgetAttribute(XCAFDoc::ClipPlaneCappingRefGUID());
Standard_Integer aCappingVal = (theCapping) ? 1 : 0;
TDataStd_Integer::Set(theClippingPlaneL, aCappingVal);
TDataStd_Integer::Set(theClippingPlaneL, XCAFDoc::ClipPlaneCappingRefGUID(), aCappingVal);
}
//=======================================================================
@@ -246,7 +252,7 @@ Standard_Boolean XCAFDoc_ClippingPlaneTool::GetCapping(const TDF_Label& theClipp
return Standard_False;
Handle(TDataStd_Integer) aCappingAttribute;
if (theClippingPlaneL.FindAttribute(TDataStd_Integer::GetID(), aCappingAttribute))
if (theClippingPlaneL.FindAttribute(XCAFDoc::ClipPlaneCappingRefGUID(), aCappingAttribute))
return (aCappingAttribute->Get() == 1);
return Standard_False;
@@ -263,13 +269,63 @@ Standard_Boolean XCAFDoc_ClippingPlaneTool::GetCapping(const TDF_Label& theClipp
return Standard_False;
Handle(TDataStd_Integer) aCappingAttribute;
if (theClippingPlaneL.FindAttribute(TDataStd_Integer::GetID(), aCappingAttribute)) {
if (theClippingPlaneL.FindAttribute(XCAFDoc::ClipPlaneCappingRefGUID(), aCappingAttribute)) {
theCapping = (aCappingAttribute->Get() == 1);
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : SetVisible
//purpose :
//=======================================================================
void XCAFDoc_ClippingPlaneTool::SetVisible(const TDF_Label& theClippingPlaneL, const Standard_Boolean theVisible)
{
if (theClippingPlaneL.Father() != Label())
return;
theClippingPlaneL.ForgetAttribute(XCAFDoc::ClipPlaneVisibleRefGUID());
Standard_Integer aVisibleVal = (theVisible) ? 1 : 0;
TDataStd_Integer::Set(theClippingPlaneL, XCAFDoc::ClipPlaneVisibleRefGUID(), aVisibleVal);
}
//=======================================================================
//function : GetVisible
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_ClippingPlaneTool::GetVisible(const TDF_Label& theClippingPlaneL) const
{
if (theClippingPlaneL.Father() != Label())
return Standard_False;
Handle(TDataStd_Integer) aVisibleAttribute;
if (theClippingPlaneL.FindAttribute(XCAFDoc::ClipPlaneVisibleRefGUID(), aVisibleAttribute))
return (aVisibleAttribute->Get() == 1);
return Standard_False;
}
//=======================================================================
//function : GetVisible
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_ClippingPlaneTool::GetVisible(const TDF_Label& theClippingPlaneL, Standard_Boolean &theVisible) const
{
if (theClippingPlaneL.Father() != Label())
return Standard_False;
Handle(TDataStd_Integer) aVisibleAttribute;
if (theClippingPlaneL.FindAttribute(XCAFDoc::ClipPlaneVisibleRefGUID(), aVisibleAttribute)) {
theVisible = (aVisibleAttribute->Get() == 1);
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : GetID

View File

@@ -48,22 +48,22 @@ public:
//! Returns ClippingPlane defined by label lab
//! Returns False if the label is not in ClippingPlane table
//! or does not define a ClippingPlane
Standard_EXPORT Standard_Boolean GetClippingPlane(const TDF_Label& theLabel, gp_Pln& thePlane, TCollection_ExtendedString& theName, Standard_Boolean &theCapping) const;
Standard_EXPORT Standard_Boolean GetClippingPlane(const TDF_Label& theLabel, gp_Pln& thePlane, TCollection_ExtendedString& theName, Standard_Boolean &theCapping, Standard_Boolean &theVisible) const;
//! Returns ClippingPlane defined by label lab
//! Returns False if the label is not in ClippingPlane table
//! or does not define a ClippingPlane
Standard_EXPORT Standard_Boolean GetClippingPlane(const TDF_Label& theLabel, gp_Pln& thePlane, Handle(TCollection_HAsciiString)& theName, Standard_Boolean &theCapping) const;
Standard_EXPORT Standard_Boolean GetClippingPlane(const TDF_Label& theLabel, gp_Pln& thePlane, Handle(TCollection_HAsciiString)& theName, Standard_Boolean &theCapping, Standard_Boolean &theVisible) const;
//! Adds a clipping plane definition to a ClippingPlane table and returns
//! its label (returns existing label if the same clipping plane
//! is already defined)
Standard_EXPORT TDF_Label AddClippingPlane(const gp_Pln thePlane, const TCollection_ExtendedString theName, const Standard_Boolean theCapping) const;
Standard_EXPORT TDF_Label AddClippingPlane(const gp_Pln thePlane, const TCollection_ExtendedString theName, const Standard_Boolean theCapping, const Standard_Boolean theVisible) const;
//! Adds a clipping plane definition to a ClippingPlane table and returns
//! its label (returns existing label if the same clipping plane
//! is already defined)
Standard_EXPORT TDF_Label AddClippingPlane(const gp_Pln thePlane, const Handle(TCollection_HAsciiString)& theName, const Standard_Boolean theCapping) const;
Standard_EXPORT TDF_Label AddClippingPlane(const gp_Pln thePlane, const Handle(TCollection_HAsciiString)& theName, const Standard_Boolean theCapping, const Standard_Boolean theVisible) const;
//! Adds a clipping plane definition to a ClippingPlane table and returns
//! its label (returns existing label if the same clipping plane
@@ -97,6 +97,17 @@ public:
//! Get capping value for given clipping plane label
//! Return true if Label is valid abd capping is exist.
Standard_EXPORT Standard_Boolean GetCapping(const TDF_Label& theClippingPlaneL, Standard_Boolean &theCapping) const;
//! Set new value of visible for given clipping plane label
Standard_EXPORT void SetVisible(const TDF_Label& theClippingPlaneL, const Standard_Boolean theCapping);
//! Get visible value for given clipping plane label
//! Return capping value
Standard_EXPORT Standard_Boolean GetVisible(const TDF_Label& theClippingPlaneL) const;
//! Get visible value for given clipping plane label
//! Return true if Label is valid abd capping is exist.
Standard_EXPORT Standard_Boolean GetVisible(const TDF_Label& theClippingPlaneL, Standard_Boolean &theCapping) const;
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;

View File

@@ -33,6 +33,7 @@
#include <XCAFDoc_NotesTool.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#include <XCAFDoc_ViewTool.hxx>
#include <XCAFDoc_AnimationTool.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_DocumentTool,TDF_Attribute)
@@ -87,6 +88,7 @@ Handle(XCAFDoc_DocumentTool) XCAFDoc_DocumentTool::Set(const TDF_Label& L,
XCAFDoc_NotesTool::Set(NotesLabel(L));
XCAFDoc_ViewTool::Set(ViewsLabel(L));
XCAFDoc_ClippingPlaneTool::Set(ClippingPlanesLabel(L));
XCAFDoc_AnimationTool::Set(AnimationsLabel(L));
}
return A;
}
@@ -224,7 +226,17 @@ TDF_Label XCAFDoc_DocumentTool::NotesLabel(const TDF_Label& acces)
TDataStd_Name::Set(L, "Notes");
return L;
}
//=======================================================================
//function : AnimationsLabel
//purpose :
//=======================================================================
TDF_Label XCAFDoc_DocumentTool::AnimationsLabel(const TDF_Label& acces)
{
TDF_Label L = DocLabel(acces).FindChild(10, Standard_True);
TDataStd_Name::Set(L, "Animations");
return L;
}
//=======================================================================
//function : ShapeTool
//purpose :
@@ -308,7 +320,15 @@ Handle(XCAFDoc_NotesTool) XCAFDoc_DocumentTool::NotesTool(const TDF_Label& acces
{
return XCAFDoc_NotesTool::Set(NotesLabel(acces));
}
//=======================================================================
//function : AnimationTool
//purpose :
//=======================================================================
Handle(XCAFDoc_AnimationTool) XCAFDoc_DocumentTool::AnimationTool(const TDF_Label& acces)
{
return XCAFDoc_AnimationTool::Set(AnimationsLabel(acces));
}
//=======================================================================
//function : ID
//purpose :

View File

@@ -34,6 +34,7 @@ class XCAFDoc_NotesTool;
class XCAFDoc_ViewTool;
class TDF_Attribute;
class TDF_RelocationTable;
class XCAFDoc_AnimationTool;
class XCAFDoc_DocumentTool;
@@ -88,6 +89,9 @@ public:
//! Returns sub-label of DocLabel() with tag 9.
Standard_EXPORT static TDF_Label NotesLabel(const TDF_Label& acces);
//! Returns sub-label of DocLabel() with tag 10.
Standard_EXPORT static TDF_Label AnimationsLabel(const TDF_Label& acces);
//! Creates (if it does not exist) ShapeTool attribute on ShapesLabel().
Standard_EXPORT static Handle(XCAFDoc_ShapeTool) ShapeTool (const TDF_Label& acces);
@@ -112,6 +116,9 @@ public:
//! Creates (if it does not exist) NotesTool attribute on NotesLabel().
Standard_EXPORT static Handle(XCAFDoc_NotesTool) NotesTool(const TDF_Label& acces);
//! Creates (if it does not exist) AnimationTool attribute on NotesLabel().
Standard_EXPORT static Handle(XCAFDoc_AnimationTool) AnimationTool(const TDF_Label& acces);
Standard_EXPORT XCAFDoc_DocumentTool();

View File

@@ -20,6 +20,7 @@
#include <TDataStd_Integer.hxx>
#include <TDataStd_Real.hxx>
#include <TDataStd_RealArray.hxx>
#include <TDataStd_ByteArray.hxx>
#include <TDataXtd_Axis.hxx>
#include <TDataXtd_Geometry.hxx>
#include <TDataXtd_Plane.hxx>
@@ -45,7 +46,10 @@ enum ChildLab
ChildLab_BackPlaneDistance,
ChildLab_ViewVolumeSidesClipping,
ChildLab_ClippingExpression,
ChildLab_GDTPoints
ChildLab_GDTPoints,
ChildLab_Image,
ChildLab_EnabledShapes,
ChildLab_NotePoints
};
//=======================================================================
@@ -149,6 +153,32 @@ void XCAFDoc_View::SetObject (const Handle(XCAFView_Object)& theObject)
TDataXtd_Point::Set(aPointsLabel.FindChild(i), theObject->GDTPoint(i));
}
}
//Image
if (theObject->HasImage())
{
Handle(TColStd_HArray1OfByte) image = theObject->Image();
Handle(TDataStd_ByteArray) arr = TDataStd_ByteArray::Set(Label().FindChild(ChildLab_Image), image->Lower(), image->Upper());
for (Standard_Integer i = image->Lower(); i <= image->Upper(); i++) {
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);
}
}
//note points
if (theObject->HasNotePoints())
{
TDF_Label aPointsLabel = Label().FindChild(ChildLab_NotePoints);
for (Standard_Integer i = 1; i <= theObject->NbNotePoints(); i++) {
TDataXtd_Point::Set(aPointsLabel.FindChild(i), theObject->NotePoint(i));
}
}
}
//=======================================================================
@@ -259,7 +289,37 @@ Handle(XCAFView_Object) XCAFDoc_View::GetObject() const
anObj->SetGDTPoint(i, aPoint);
}
}
//Image
Handle(TDataStd_ByteArray) anArr;
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);
}
}
// Note Points
if (!Label().FindChild(ChildLab_NotePoints, Standard_False).IsNull()) {
TDF_Label aPointsLabel = Label().FindChild(ChildLab_NotePoints);
anObj->CreateNotePoints(aPointsLabel.NbChildren());
for (Standard_Integer i = 1; i <= aPointsLabel.NbChildren(); i++) {
gp_Pnt aPoint;
Handle(TDataXtd_Point) aPointAttr;
aPointsLabel.FindChild(i).FindAttribute(TDataXtd_Point::GetID(), aPointAttr);
TDataXtd_Geometry::Point(aPointAttr->Label(), aPoint);
anObj->SetNotePoint(i, aPoint);
}
}
return anObj;
}

View File

@@ -305,11 +305,10 @@ void XCAFDoc_ViewTool::SetView(const TDF_LabelSequence& theShapeLabels,
aPlaneGNode = aChGNode->GetFather(1);
aPlaneGNode->UnSetChild(aChGNode);
if (aPlaneGNode->NbChildren() == 0)
aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefGDTGUID());
aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefPlaneGUID());
}
theViewL.ForgetAttribute(XCAFDoc::ViewRefPlaneGUID());
}
if (!theViewL.FindAttribute(XCAFDoc::ViewRefShapeGUID(), aChGNode) && theShapeLabels.Length() > 0) {
aChGNode = new XCAFDoc_GraphNode;
aChGNode = XCAFDoc_GraphNode::Set(theViewL);
@@ -444,7 +443,7 @@ void XCAFDoc_ViewTool::SetClippingPlanes(const TDF_LabelSequence& theClippingPla
aPlaneGNode = aChGNode->GetFather(1);
aPlaneGNode->UnSetChild(aChGNode);
if (aPlaneGNode->NbChildren() == 0)
aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefGDTGUID());
aPlaneGNode->ForgetAttribute(XCAFDoc::ViewRefPlaneGUID());
}
theViewL.ForgetAttribute(XCAFDoc::ViewRefPlaneGUID());
}
@@ -465,7 +464,86 @@ 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) aShapeGNode;
if (theViewL.FindAttribute(XCAFDoc::ViewRefEnabledShapesGUID(), aChGNode)) {
while (aChGNode->NbFathers() > 0) {
aShapeGNode = aChGNode->GetFather(1);
aShapeGNode->UnSetChild(aChGNode);
if (aShapeGNode->NbChildren() == 0)
aShapeGNode->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(), aShapeGNode)) {
aShapeGNode = new XCAFDoc_GraphNode;
aShapeGNode = XCAFDoc_GraphNode::Set(theShapesTransparencyLabels.Value(i));
}
aShapeGNode->SetGraphID(XCAFDoc::ViewRefEnabledShapesGUID());
aShapeGNode->SetChild(aChGNode);
aChGNode->SetFather(aShapeGNode);
}
}
//=======================================================================
//function : SetNotes
//purpose :
//=======================================================================
void XCAFDoc_ViewTool::SetNotes(const TDF_LabelSequence& theNoteLabels,
const TDF_Label& theViewL) const
{
if (!IsView(theViewL))
return;
Handle(XCAFDoc_GraphNode) aChGNode;
Handle(XCAFDoc_GraphNode) aNoteGNode;
if (theViewL.FindAttribute(XCAFDoc::ViewRefNoteGUID(), aChGNode)) {
while (aChGNode->NbFathers() > 0) {
aNoteGNode = aChGNode->GetFather(1);
aNoteGNode->UnSetChild(aChGNode);
if (aNoteGNode->NbChildren() == 0)
aNoteGNode->ForgetAttribute(XCAFDoc::ViewRefNoteGUID());
}
theViewL.ForgetAttribute(XCAFDoc::ViewRefNoteGUID());
}
if (!theViewL.FindAttribute(XCAFDoc::ViewRefNoteGUID(), aChGNode) && theNoteLabels.Length() > 0) {
aChGNode = new XCAFDoc_GraphNode;
aChGNode = XCAFDoc_GraphNode::Set(theViewL);
aChGNode->SetGraphID(XCAFDoc::ViewRefNoteGUID());
}
for (Standard_Integer i = theNoteLabels.Lower(); i <= theNoteLabels.Upper(); i++)
{
if (!theNoteLabels.Value(i).FindAttribute(XCAFDoc::ViewRefNoteGUID(), aNoteGNode)) {
aNoteGNode = new XCAFDoc_GraphNode;
aNoteGNode = XCAFDoc_GraphNode::Set(theNoteLabels.Value(i));
}
aNoteGNode->SetGraphID(XCAFDoc::ViewRefNoteGUID());
aNoteGNode->SetChild(aChGNode);
aChGNode->SetFather(aNoteGNode);
}
}
//=======================================================================
//function : RemoveView
//purpose :
@@ -579,6 +657,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 :
@@ -684,6 +786,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 :

View File

@@ -86,6 +86,12 @@ 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;
//! Set Notes to given View
Standard_EXPORT void SetNotes(const TDF_LabelSequence& theNoteLabels,
const TDF_Label& theViewL) const;
//! Remove View
Standard_EXPORT void RemoveView(const TDF_Label& theViewL);
@@ -105,6 +111,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 +129,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;

View File

@@ -28,6 +28,9 @@ XCAFView_Object::XCAFView_Object()
myBackPlaneClipping = Standard_False;
myViewVolumeSidesClipping = Standard_False;
myGDTPoints = NULL;
myImage = NULL;
myEnabledShapes = NULL;
myNotePoints = NULL;
}
//=======================================================================
@@ -50,5 +53,8 @@ XCAFView_Object::XCAFView_Object(const Handle(XCAFView_Object)& theObj)
myBackPlaneDistance = theObj->myBackPlaneDistance;
myViewVolumeSidesClipping = theObj->myViewVolumeSidesClipping;
myGDTPoints = NULL;
myImage = theObj->myImage;
myEnabledShapes = NULL;
myGDTPoints = NULL;
}

View File

@@ -26,6 +26,8 @@
#include <TColgp_HArray1OfPnt.hxx>
#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)
@@ -217,7 +219,93 @@ public:
else
return gp_Pnt();
}
Standard_EXPORT void SetImage(Handle(TColStd_HArray1OfByte) theImage)
{
myImage = theImage;
}
Standard_EXPORT Handle(TColStd_HArray1OfByte) Image()
{
return myImage;
}
Standard_EXPORT Standard_Boolean HasImage()
{
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;
}
Standard_EXPORT void CreateNotePoints(const Standard_Integer theLenght)
{
if (theLenght > 0)
myNotePoints = new TColgp_HArray1OfPnt(1, theLenght);
}
Standard_EXPORT Standard_Boolean HasNotePoints()
{
return (!myNotePoints.IsNull());
}
Standard_EXPORT Standard_Integer NbNotePoints()
{
if (myNotePoints.IsNull())
return 0;
return myNotePoints->Length();
}
Standard_EXPORT void SetNotePoint(const Standard_Integer theIndex, const gp_Pnt thePoint)
{
if (myNotePoints.IsNull())
return;
if (theIndex > 0 && theIndex <= myNotePoints->Length())
myNotePoints->SetValue(theIndex, thePoint);
}
Standard_EXPORT gp_Pnt NotePoint(const Standard_Integer theIndex)
{
if (myNotePoints.IsNull())
return gp_Pnt();
if (theIndex > 0 && theIndex <= myNotePoints->Length())
return myNotePoints->Value(theIndex);
else
return gp_Pnt();
}
DEFINE_STANDARD_RTTIEXT(XCAFView_Object,Standard_Transient)
private:
@@ -237,6 +325,9 @@ private:
Standard_Real myBackPlaneDistance;
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;
Handle(TColgp_HArray1OfPnt) myNotePoints;
};
#endif // _XCAFView_Object_HeaderFile

View File

@@ -16,3 +16,6 @@ XDEDRAW_Views.cxx
XDEDRAW_Views.hxx
XDEDRAW_Notes.cxx
XDEDRAW_Notes.hxx
XDEDRAW_Animations.cxx
XDEDRAW_Animations.hxx

View File

@@ -88,6 +88,7 @@
#include <XDEDRAW_GDTs.hxx>
#include <XDEDRAW_Views.hxx>
#include <XDEDRAW_Notes.hxx>
#include <XDEDRAW_Animations.hxx>
#include <XSDRAW.hxx>
#include <XSDRAWIGES.hxx>
#include <XSDRAWSTEP.hxx>
@@ -1201,6 +1202,7 @@ void XDEDRAW::Init(Draw_Interpretor& di)
XDEDRAW_GDTs::InitCommands ( di );
XDEDRAW_Views::InitCommands(di);
XDEDRAW_Notes::InitCommands(di);
XDEDRAW_Animations::InitCommands( di );
XDEDRAW_Common::InitCommands ( di );//moved from EXE
}

View File

@@ -0,0 +1,376 @@
// Created on: 2017-10-02
// Created by: Elena MOZOKHINA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <DDocStd.hxx>
#include <OSD_File.hxx>
#include <OSD_Protection.hxx>
#include <TDocStd_Document.hxx>
#include <TDF_Tool.hxx>
#include <TCollection_HAsciiString.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XCAFDoc_AnimationTool.hxx>
#include <XDEDRAW_Animations.hxx>
#include <XCAFDoc_Animation.hxx>
struct cmd
{
const char* name;
Standard_Integer nargsreq;
const char* use;
};
//=======================================================================
//function : animations
//purpose : returns list of all animations
//=======================================================================
static const cmd XAnimations = {
"XAnimations", 2, "XAnimations Doc"
};
static Standard_Integer
animations(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
static const cmd& myCommand = XAnimations;
if (argc < myCommand.nargsreq)
{
di << "Use: " << myCommand.use << "\n";
return 1;
}
Handle(TDocStd_Document) aDoc;
DDocStd::GetDocument(argv[1], aDoc);
if (aDoc.IsNull())
{
return 1;
}
Handle(XCAFDoc_AnimationTool) anAnimTool = XCAFDoc_DocumentTool::AnimationTool(aDoc->Main());
TDF_LabelSequence anAnimations;
anAnimTool->GetAnimationLabels(anAnimations);
for (TDF_LabelSequence::Iterator anIt(anAnimations); anIt.More(); anIt.Next())
{
TCollection_AsciiString anEntry;
TDF_Tool::Entry(anIt.Value(), anEntry);
di << anEntry << " ";
}
return 0;
}
//=======================================================================
//function : addAnimation
//purpose : add animation
//=======================================================================
static const cmd XAnimationAdd = {
"XAnimationAdd", 6, "XAnimationAdd Doc name --file image_path animation_path | --data image_data animation_data"
};
static Standard_Integer
addAnimation(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
static const cmd& myCommand = XAnimationAdd;
if (argc < myCommand.nargsreq)
{
di << "Use: " << myCommand.use << "\n";
return 1;
}
Standard_Integer iarg = 0;
Handle(TDocStd_Document) aDoc;
DDocStd::GetDocument(argv[++iarg], aDoc);
if (aDoc.IsNull())
{
return 1;
}
TCollection_ExtendedString aName = argv[++iarg];
Standard_Boolean aFromFile = Standard_False;
Standard_Boolean aFromData = Standard_False;
TCollection_ExtendedString anImageFileStr;
TCollection_ExtendedString anAnimationFileStr;
Handle(TColStd_HArray1OfByte) anImage;
Handle(TColStd_HArray1OfByte) anAnimation;
for (++iarg; iarg < argc; ++iarg)
{
TCollection_AsciiString opt = argv[iarg];
if (opt == "--file")
{
if (aFromData)
{
di << "Error: data can be taken either from a file or a data array.\n";
di << "Use: " << myCommand.use << "\n";
return 1;
}
if (++iarg >= argc)
{
di << "Error: file image path is expected.\n";
di << "Use: " << myCommand.use << "\n";
return 1;
}
anImageFileStr = argv[iarg];
if (++iarg >= argc)
{
di << "Error: file animation path is expected.\n";
di << "Use: " << myCommand.use << "\n";
return 1;
}
anAnimationFileStr = argv[iarg];
aFromFile = Standard_True;
}
else if (opt == "--data")
{
if (aFromFile)
{
di << "Error: data can be taken either from a file or a data array.\n";
di << "Use: " << myCommand.use << "\n";
return 1;
}
if (++iarg >= argc)
{
di << "Error: image data array is expected.\n";
di << "Use: " << myCommand.use << "\n";
return 1;
}
Standard_SStream ss(std::ios_base::in | std::ios_base::out | std::ios_base::binary);
ss << argv[iarg];
Standard_Integer len = static_cast<Standard_Integer>(ss.tellp());
anImage = new TColStd_HArray1OfByte(1, len);
for (Standard_Integer i = 1; i <= len && !ss.eof(); ++i)
{
ss >> anImage->ChangeValue(i);
}
if (++iarg >= argc)
{
di << "Error: animation data array is expected.\n";
di << "Use: " << myCommand.use << "\n";
return 1;
}
Standard_SStream ssAn(std::ios_base::in | std::ios_base::out | std::ios_base::binary);
ssAn << argv[iarg];
len = static_cast<Standard_Integer>(ss.tellp());
anAnimation = new TColStd_HArray1OfByte(1, len);
for (Standard_Integer i = 1; i <= len && !ss.eof(); ++i)
{
ssAn >> anAnimation->ChangeValue(i);
}
aFromData = Standard_True;
}
}
Handle(XCAFDoc_AnimationTool) anAnimationTool = XCAFDoc_DocumentTool::AnimationTool(aDoc->Main());
TDF_Label aLabel;
if (aFromFile)
{
OSD_Path anImagePath(anImageFileStr);
OSD_File anImageFile(anImagePath);
anImageFile.Open(OSD_ReadOnly, OSD_Protection());
OSD_Path anAnimPath(anAnimationFileStr);
OSD_File anAnimFile(anAnimPath);
anAnimFile.Open(OSD_ReadOnly, OSD_Protection());
aLabel = anAnimationTool->AddAnimation(new TCollection_HAsciiString(aName), anImageFile, anAnimFile);
}
else if (aFromData)
{
aLabel = anAnimationTool->AddAnimation(new TCollection_HAsciiString(aName), anImage, anAnimation);
}
else
{
di << "Error: data can be taken either from a file or a data array.\n";
di << "Use: " << myCommand.use << "\n";
return 1;
}
TCollection_AsciiString anEntry;
TDF_Tool::Entry(aLabel, anEntry);
di << anEntry;
return 0;
}
//=======================================================================
//function : removeAnimation
//purpose : deletes an animation
//=======================================================================
static const cmd XAnimationRemove = {
"XAnimationRemove", 3, "XAnimationRemove Doc animation"
};
static Standard_Integer
removeAnimation(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
static const cmd& myCommand = XAnimationRemove;
if (argc < myCommand.nargsreq)
{
di << "Use: " << myCommand.use << "\n";
return 1;
}
Handle(TDocStd_Document) aDoc;
DDocStd::GetDocument(argv[1], aDoc);
if (aDoc.IsNull())
{
return 1;
}
TCollection_ExtendedString anEntry = argv[2];
TDF_Label aLabel;
TDF_Tool::Label(aDoc->GetData(), anEntry, aLabel);
if (aLabel.IsNull())
{
di << anEntry << ": invalid animation entry.\n";
return 1;
}
Handle(XCAFDoc_AnimationTool) anAnimationTool = XCAFDoc_DocumentTool::AnimationTool(aDoc->Main());
if (!anAnimationTool->RemoveAnimation(aLabel))
{
di << "Error: couldn't remove animation.\n";
return 1;
}
return 0;
}
//=======================================================================
//function : animationDump
//purpose : dump an animation
//=======================================================================
static const cmd XAnimationDump = {
"XAnimationDump", 3, "XAnimationDump Doc animation"
};
static Standard_Integer
animationDump(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
static const cmd& myCommand = XAnimationDump;
if (argc < myCommand.nargsreq)
{
di << "Use: " << myCommand.use << "\n";
return 1;
}
Standard_Integer iarg = 0;
Handle(TDocStd_Document) aDoc;
DDocStd::GetDocument(argv[++iarg], aDoc);
if (aDoc.IsNull())
{
return 1;
}
TCollection_AsciiString anEntry = argv[++iarg];
TDF_Label aLabel;
TDF_Tool::Label(aDoc->GetData(), anEntry, aLabel);
if (aLabel.IsNull())
{
TCollection_AsciiString anEntry;
TDF_Tool::Entry(aLabel, anEntry);
di << anEntry << ": invalid animation entry.\n";
return 1;
}
Handle(XCAFDoc_AnimationTool) anAnimTool = XCAFDoc_DocumentTool::AnimationTool(aDoc->Main());
Handle(TCollection_HAsciiString) aName;
Handle(TColStd_HArray1OfByte) anImage, anAnimation;
anAnimTool->GetAnimation(aLabel, aName, anImage, anAnimation);
if (!aName.IsNull())
{
di <<"Name : " << aName->ToCString() << "\n";
}
static Standard_Integer theMaxLen = 64;
if (!anImage.IsNull())
{
di << "Image size : " << anImage->Length()<<"\n";
}
else
{
di << "Image is NULL \n ";
}
if (!anAnimation.IsNull())
{
di << "Animation size : " << anAnimation->Length()<<"\n";
}
else
{
di << "Animation is NULL \n ";
}
return 0;
}
//=======================================================================
//function : setName
//purpose : rename animation
//=======================================================================
static const cmd XAnimationSetName = {
"XAnimationSetName", 4, "XAnimationSetName Doc animation new_name"
};
static Standard_Integer
setName(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
static const cmd& myCommand = XAnimationSetName;
if (argc < myCommand.nargsreq)
{
di << "Use: " << myCommand.use << "\n";
return 1;
}
Handle(TDocStd_Document) aDoc;
DDocStd::GetDocument(argv[1], aDoc);
if (aDoc.IsNull())
{
return 1;
}
TCollection_ExtendedString anEntry = argv[2];
TDF_Label aLabel;
TDF_Tool::Label(aDoc->GetData(), anEntry, aLabel);
if (aLabel.IsNull())
{
di << anEntry << ": invalid animation entry.\n";
return 1;
}
Handle(XCAFDoc_AnimationTool) anAnimTool = XCAFDoc_DocumentTool::AnimationTool(aDoc->Main());
anAnimTool->SetName(aLabel, new TCollection_HAsciiString(argv[3]));
return 0;
}
//=======================================================================
//function : InitCommands
//purpose :
//=======================================================================
void XDEDRAW_Animations::InitCommands(Draw_Interpretor& di)
{
static Standard_Boolean initialized = Standard_False;
if (initialized)
{
return;
}
initialized = Standard_True;
Standard_CString g = "XDE Animations commands";
di.Add(XAnimations.name, XAnimations.use, __FILE__, animations, g);
di.Add(XAnimationAdd.name, XAnimationAdd.use, __FILE__, addAnimation, g);
di.Add(XAnimationRemove.name, XAnimationRemove.use, __FILE__, removeAnimation, g);
di.Add(XAnimationDump.name, XAnimationDump.use, __FILE__, animationDump, g);
di.Add(XAnimationSetName.name, XAnimationSetName.use, __FILE__, setName, g);
}

View File

@@ -0,0 +1,35 @@
// Created on: 2017-10-02
// Created by: Elena Mozokhina
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _XDEDRAW_Animations_HeaderFile
#define _XDEDRAW_Animations_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Draw_Interpretor.hxx>
//! Contains commands to work with notes
class XDEDRAW_Animations
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT static void InitCommands (Draw_Interpretor& theCommands);
};
#endif // _XDEDRAW_Animations_HeaderFile

View File

@@ -1175,8 +1175,8 @@ static Standard_Integer dump(Draw_Interpretor& di, Standard_Integer argc, const
//=======================================================================
static Standard_Integer addClippingPlane(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 5) {
di << "Use: XAddClippingPlane Doc plane name capping[0/1]";
if (argc < 6) {
di << "Use: XAddClippingPlane Doc plane name capping[0/1] visible[0/1]";
return 1;
}
Handle(TDocStd_Document) aDoc;
@@ -1195,8 +1195,9 @@ static Standard_Integer addClippingPlane(Draw_Interpretor& di, Standard_Integer
aPlane = aSurf->Pln();
Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(argv[3]);
Standard_Boolean aCapping = (argv[4][0] == '1');
Standard_Boolean aVisible = (argv[5][0] == '1');
TDF_Label aCPlaneL = aCPlaneTool->AddClippingPlane(aPlane, aName, aCapping);
TDF_Label aCPlaneL = aCPlaneTool->AddClippingPlane(aPlane, aName, aCapping, aVisible);
TCollection_AsciiString anEntry;
TDF_Tool::Entry(aCPlaneL, anEntry);
di << anEntry << "\n";
@@ -1230,8 +1231,8 @@ static Standard_Integer getClippingPlane(Draw_Interpretor& di, Standard_Integer
}
gp_Pln aPlane;
Handle(TCollection_HAsciiString) aName;
Standard_Boolean aCapping;
aClippingPlaneTool->GetClippingPlane(aLabel, aPlane, aName, aCapping);
Standard_Boolean aCapping, aVisible;
aClippingPlaneTool->GetClippingPlane(aLabel, aPlane, aName, aCapping, aVisible);
Handle(Geom_Plane) aCPlane = new Geom_Plane(aPlane);
DrawTrSurf::Set(aName->ToCString(), aCPlane);
di << aName->ToCString();

View File

@@ -47,3 +47,8 @@ XmlMXCAFDoc_ViewToolDriver.cxx
XmlMXCAFDoc_ViewToolDriver.hxx
XmlMXCAFDoc_VolumeDriver.cxx
XmlMXCAFDoc_VolumeDriver.hxx
XmlMXCAFDoc_AnimationDriver.cxx
XmlMXCAFDoc_AnimationDriver.hxx
XmlMXCAFDoc_AnimationToolDriver.cxx
XmlMXCAFDoc_AnimationToolDriver.hxx

View File

@@ -0,0 +1,152 @@
// Created on: 2017-10-02
// Created by: Elena MOZOKHINA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Message_Messenger.hxx>
#include <Standard_Type.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TColStd_HArray1OfByte.hxx>
#include <TDF_Attribute.hxx>
#include <XCAFDoc_Animation.hxx>
#include <XmlMXCAFDoc_AnimationDriver.hxx>
#include <XmlObjMgt.hxx>
#include <XmlObjMgt_Persistent.hxx>
#include <LDOM_OSStream.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_AnimationDriver,XmlMDF_ADriver)
IMPLEMENT_DOMSTRING (AnimationName, "name")
IMPLEMENT_DOMSTRING (ImageFirstIdx, "image_first_idx")
IMPLEMENT_DOMSTRING (ImageLastIdx, "image_last_idx")
IMPLEMENT_DOMSTRING(AnimationFirstIdx, "animation_first_idx")
IMPLEMENT_DOMSTRING(AnimationLastIdx, "animation_last_idx")
//=======================================================================
//function : XmlMXCAFDoc_AnimationDriver
//purpose : Constructor
//=======================================================================
XmlMXCAFDoc_AnimationDriver::XmlMXCAFDoc_AnimationDriver
(const Handle(Message_Messenger)& theMsgDriver)
: XmlMDF_ADriver (theMsgDriver, "xcaf", "Animation")
{}
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) XmlMXCAFDoc_AnimationDriver::NewEmpty() const
{
return (new XCAFDoc_Animation());
}
//=======================================================================
//function : Paste
//purpose : persistent -> transient (retrieve)
//=======================================================================
Standard_Boolean XmlMXCAFDoc_AnimationDriver::Paste
(const XmlObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
XmlObjMgt_RRelocationTable& ) const
{
const XmlObjMgt_Element& anElement = theSource;
Handle(XCAFDoc_Animation) aTarget = Handle(XCAFDoc_Animation)::DownCast(theTarget);
if (aTarget.IsNull())
return Standard_False;
XmlObjMgt_DOMString aNameStr = anElement.getAttribute(::AnimationName());
XmlObjMgt_DOMString anImageFirstIdxStr = anElement.getAttribute(::ImageFirstIdx());
XmlObjMgt_DOMString anImageLastIdxStr = anElement.getAttribute(::ImageLastIdx());
XmlObjMgt_DOMString anAnimFirstIdxStr = anElement.getAttribute(::AnimationFirstIdx());
XmlObjMgt_DOMString anAnimLastIdxStr = anElement.getAttribute(::AnimationLastIdx());
if (aNameStr == NULL || anImageFirstIdxStr == NULL || anImageLastIdxStr == NULL ||
anAnimFirstIdxStr == NULL || anAnimLastIdxStr == NULL)
return Standard_False;
Standard_Integer anImageFirstIdx = 0;
Standard_Integer anImageLastIdx = 0;
if (!anImageFirstIdxStr.GetInteger(anImageFirstIdx) || !anImageLastIdxStr.GetInteger(anImageLastIdx))
return Standard_False;
Handle(TColStd_HArray1OfByte) anImage = new TColStd_HArray1OfByte(anImageFirstIdx, anImageLastIdx);
Standard_Integer anAnimFirstIdx = 0;
Standard_Integer anAnimLastIdx = 0;
if (!anAnimFirstIdxStr.GetInteger(anAnimFirstIdx) || !anAnimLastIdxStr.GetInteger(anAnimLastIdx))
return Standard_False;
Handle(TColStd_HArray1OfByte) anAnim = new TColStd_HArray1OfByte(anAnimFirstIdx, anAnimLastIdx);
const Standard_Integer aMaxSize = anImageLastIdx - anImageFirstIdx + anAnimLastIdx - anAnimFirstIdx + 2;
XmlObjMgt_DOMString aDataStr = XmlObjMgt::GetStringValue(theSource);
Standard_SStream anSS(aDataStr.GetString());
Standard_Byte aValue;
for (Standard_Integer i = anImageFirstIdx; i <= anImageLastIdx; ++i)
{
anSS >> aValue;
anImage->ChangeValue(i) = aValue;
}
for (Standard_Integer i = anAnimFirstIdx; i <= anAnimLastIdx; ++i)
{
anSS >> aValue;
anAnim->ChangeValue(i) = aValue;
}
aTarget->Set(new TCollection_HAsciiString(aNameStr.GetString()), anImage, anImage);
return Standard_True;
}
//=======================================================================
//function : Paste
//purpose : transient -> persistent (store)
//=======================================================================
void XmlMXCAFDoc_AnimationDriver::Paste(const Handle(TDF_Attribute)& theSource,
XmlObjMgt_Persistent& theTarget,
XmlObjMgt_SRelocationTable&) const
{
Handle(XCAFDoc_Animation) anAnimation = Handle(XCAFDoc_Animation)::DownCast(theSource);
if (anAnimation.IsNull())
return;
XmlObjMgt_DOMString aName = anAnimation->GetName()->String().ToCString();
theTarget.Element().setAttribute(::AnimationName(), aName);
Handle(TColStd_HArray1OfByte) anImage = anAnimation->GetImage();
Handle(TColStd_HArray1OfByte) anAnim = anAnimation->GetAnimation();
if (anImage.IsNull() || anAnim.IsNull())
{
return;
}
const Standard_Integer anImageFirstInd = anImage->Lower();
const Standard_Integer anImageLastInd = anAnim->Upper();
const Standard_Integer anAnimFirstInd = anAnim->Lower();
const Standard_Integer anAnimLastInd = anAnim->Upper();
const Standard_Integer aMaxSize = anImageLastInd - anImageFirstInd + anAnimLastInd - anAnimFirstInd + 2;
LDOM_OSStream anOSS(aMaxSize);
for (Standard_Integer i = anImageFirstInd; i <= anImageLastInd; ++i)
{
anOSS << std::hex << anImage->Value(i);
}
for (Standard_Integer i = anAnimFirstInd; i <= anAnimLastInd; ++i)
{
anOSS << std::hex << anAnim->Value(i);
}
Standard_Character* dump = (Standard_Character*)anOSS.str(); // copying! Don't forget to delete it.
XmlObjMgt::SetStringValue(theTarget, dump, Standard_True);
delete[] dump;
}

View File

@@ -0,0 +1,51 @@
// Created on: 2017-10-02
// Created by: Elena MOZOKHINA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _XmlMXCAFDoc_AnimationDriver_HeaderFile
#define _XmlMXCAFDoc_AnimationDriver_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <XmlMDF_ADriver.hxx>
#include <Standard_Boolean.hxx>
#include <XmlObjMgt_RRelocationTable.hxx>
#include <XmlObjMgt_SRelocationTable.hxx>
class Message_Messenger;
class TDF_Attribute;
class XmlObjMgt_Persistent;
class XmlMXCAFDoc_AnimationDriver;
DEFINE_STANDARD_HANDLE(XmlMXCAFDoc_AnimationDriver, XmlMDF_ADriver)
//! Attribute Driver.
class XmlMXCAFDoc_AnimationDriver : public XmlMDF_ADriver
{
public:
Standard_EXPORT XmlMXCAFDoc_AnimationDriver(const Handle(Message_Messenger)& theMessageDriver);
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean Paste (const XmlObjMgt_Persistent& Source, const Handle(TDF_Attribute)& Target, XmlObjMgt_RRelocationTable& RelocTable) const Standard_OVERRIDE;
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& Source, XmlObjMgt_Persistent& Target, XmlObjMgt_SRelocationTable& RelocTable) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(XmlMXCAFDoc_AnimationDriver,XmlMDF_ADriver)
};
#endif // _XmlMXCAFDoc_AnimationDriver_HeaderFile

View File

@@ -0,0 +1,63 @@
// Created on: 2017-10-02
// Created by: Elena MOZOKHINA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Message_Messenger.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <XCAFDoc_AnimationTool.hxx>
#include <XmlMXCAFDoc_AnimationToolDriver.hxx>
#include <XmlObjMgt_Persistent.hxx>
IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_AnimationToolDriver,XmlMDF_ADriver)
//=======================================================================
//function :
//purpose :
//=======================================================================
XmlMXCAFDoc_AnimationToolDriver::XmlMXCAFDoc_AnimationToolDriver
(const Handle(Message_Messenger)& theMsgDriver)
: XmlMDF_ADriver (theMsgDriver, "xcaf", "AnimationTool")
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(TDF_Attribute) XmlMXCAFDoc_AnimationToolDriver::NewEmpty() const
{
return new XCAFDoc_AnimationTool();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean XmlMXCAFDoc_AnimationToolDriver::Paste(const XmlObjMgt_Persistent& ,
const Handle(TDF_Attribute)& ,
XmlObjMgt_RRelocationTable& ) const
{
return Standard_True;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void XmlMXCAFDoc_AnimationToolDriver::Paste(const Handle(TDF_Attribute)& ,
XmlObjMgt_Persistent& ,
XmlObjMgt_SRelocationTable& ) const
{
}

View File

@@ -0,0 +1,52 @@
// Created on: 2017-10-02
// Created by: Elena MOZOKHINA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _XmlMXCAFDoc_AnimationToolDriver_HeaderFile
#define _XmlMXCAFDoc_AnimationToolDriver_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <XmlMDF_ADriver.hxx>
#include <Standard_Boolean.hxx>
#include <XmlObjMgt_RRelocationTable.hxx>
#include <XmlObjMgt_SRelocationTable.hxx>
class Message_Messenger;
class TDF_Attribute;
class XmlObjMgt_Persistent;
class XmlMXCAFDoc_AnimationToolDriver;
DEFINE_STANDARD_HANDLE(XmlMXCAFDoc_AnimationToolDriver, XmlMDF_ADriver)
//! Attribute Driver.
class XmlMXCAFDoc_AnimationToolDriver : public XmlMDF_ADriver
{
public:
Standard_EXPORT XmlMXCAFDoc_AnimationToolDriver(const Handle(Message_Messenger)& theMsgDriver);
Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Paste (const XmlObjMgt_Persistent& theSource, const Handle(TDF_Attribute)& theTarget, XmlObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& theSource, XmlObjMgt_Persistent& theTarget, XmlObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(XmlMXCAFDoc_AnimationToolDriver,XmlMDF_ADriver)
};
#endif // _XmlMXCAFDoc_AnimationToolDriver_HeaderFile

View File

@@ -46,6 +46,7 @@ vclipplane change pln2 equation -0.707 0.707 0 -25
vclipplane change pln2 capping on
vclipplane change pln2 capping color 0.5 0.5 0.9
vclipplane change pln2 capping hatch on
vclipplane change pln2 capping hatchStipple 7
vclipplane set pln2 object b3
checkcolor $x3_coord $y3_coord 0.5 0.5 0.9

View File

@@ -72,5 +72,5 @@ vdisplay pp1 pp2
vzoom 0.8
puts "Enable capping planes"
vclipplane pln1 -set -equation 0 0 -1 $aPln1Z -capping 1 -color 0.5 0.5 0.5 -texname $aHatch -texscale 0.02 -0.02 -useObjMaterial 1
vclipplane pln2 -set -equation 0 1 0 [expr -$aPln2Y] -capping 1 -color 0.8 0.8 0.9 -texname $aHatch -texscale 0.02 -0.02
vclipplane pln1 -set -equation 0 0 -1 $aPln1Z -capping 1 -color 0.5 0.5 0.5 -hatchtexture $aHatch -hatchscale 0.02 -0.02 -useObjMaterial 1
vclipplane pln2 -set -equation 0 1 0 [expr -$aPln2Y] -capping 1 -color 0.8 0.8 0.9 -hatchtexture $aHatch -hatchscale 0.02 -0.02

View File

@@ -0,0 +1,64 @@
puts "=================================="
puts "AIS_ViewCube - display and erase with default settings"
puts "=================================="
set anImage1 $imagedir/${casename}_1.png
set anImage2 $imagedir/${casename}_2.png
set anImage3 $imagedir/${casename}_3.png
set anImage4 $imagedir/${casename}_4.png
vclear
vclose ALL
vinit
# -------------------------------------
# create helper object
# -------------------------------------
box aBox1 15 20 70
vdisplay aBox1 -dispMode 1
vaxo
vfit
# -------------------------------------
# display view cube object
# -------------------------------------
vviewcube -enable -size 70 -adaptsize -position 120 250
vmoveto 118 230
if {[vreadpixel 118 230 name] != "DARKTURQUOISE 1"} {
puts "ERROR: Highlighting of view cube side is wrong."
}
vmoveto 0 0
vdump $anImage1
# -------------------------------------
# Check side
# -------------------------------------
vselect 125 200
if {[vreadpixel 115 233 name] != "GRAY95 1"} {
puts "ERROR: Display of view cube is wrong."
}
if {[vreadpixel 190 136 name] != "IVORY 1"} {
puts "ERROR: Position of TOP camera is wrong."
}
vdump $anImage2
# -------------------------------------
# Check edge
# -------------------------------------
vselect 163 242
if {[vreadpixel 141 234 name] != "GRAY76 1"} {
puts "ERROR: Position of TOP-RIGHT camera is wrong."
}
vdump $anImage3
# -------------------------------------
# Check vertex
# -------------------------------------
vselect 121 213
if {[vreadpixel 120 250 name] != "GRAY95 1"} {
puts "ERROR: Position of TOP-RIGHT-BACK camera is wrong."
}
vdump $anImage4
vviewcube -remove
vclear

46
tests/v3d/viewcube/move Normal file
View File

@@ -0,0 +1,46 @@
puts "=================================="
puts "AIS_ViewCube - check positioning of View Cube"
puts "=================================="
set anImage1 $imagedir/${casename}_1.png
set anImage2 $imagedir/${casename}_2.png
set anImage3 $imagedir/${casename}_3.png
set anImage4 $imagedir/${casename}_4.png
vclear
vclose ALL
vinit
# -------------------------------------
# display view cube object
# -------------------------------------
vviewcube -enable -size 70 -adaptsize
# -------------------------------------
# check positioning of view cube object
# -------------------------------------
if {[vreadpixel 96 285 name] != "GRAY68 1"} {
puts "ERROR: Bottom left View Cube fails."
}
vdump $anImage1
vviewcube -position 200 200
if {[vreadpixel 200 176 name] != "GRAY68 1"} {
puts "ERROR: Center View Cube fails."
}
vdump $anImage2
vviewcube -position 310 100
if {[vreadpixel 310 73 name] != "GRAY68 1"} {
puts "ERROR: Top right View Cube fails."
}
vdump $anImage3
vviewcube -position 140 240
if {[vreadpixel 140 217 name] != "GRAY68 1"} {
puts "ERROR: Custom View Cube fails."
}
vdump $anImage4
vviewcube -remove
vclear

33
tests/v3d/viewcube/part Normal file
View File

@@ -0,0 +1,33 @@
puts "====================================="
puts "AIS_ViewCube - test custom appearance"
puts "====================================="
set anImage1 $imagedir/${casename}_1.png
set anImage2 $imagedir/${casename}_2.png
set anImage3 $imagedir/${casename}_3.png
vclear
vclose ALL
vinit
vviewcube -enable -hideedges
if {[vreadpixel 186 236 name] != "BLACK 0"} {
puts "ERROR: Invalid display of View Cube without edges."
}
vdump $anImage1
vviewcube -showedges -hidevertices
if {[vreadpixel 150 258 name] != "BLACK 0"} {
puts "ERROR: Invalid display of View Cube without vertices."
}
vdump $anImage2
vviewcube -hideedges -hidevertices
if {[vreadpixel 186 236 name] != "BLACK 0" || [vreadpixel 150 258 name] != "BLACK 0"} {
puts "ERROR: Invalid display of View Cube without edges & vertices."
}
vdump $anImage3
vviewcube -remove
vclear

82
tests/v3d/viewcube/style Normal file
View File

@@ -0,0 +1,82 @@
puts "=================================="
puts "AIS_ViewCube - display custom styled View Cube"
puts "=================================="
set anImage1 $imagedir/${casename}_1.png
set anImage2 $imagedir/${casename}_2.png
set anImage3 $imagedir/${casename}_3.png
set anImage4 $imagedir/${casename}_4.png
set anImage5 $imagedir/${casename}_5.png
set anImage6 $imagedir/${casename}_6.png
set anImage7 $imagedir/${casename}_7.png
vclear
vclose ALL
vinit
# -------------------------------------
# Color
# -------------------------------------
vviewcube -enable -boxcolor 0.69 0.88 1 -arrowcolor 0 0.4 0.54 -textcolor 0 0.4 0.54
if {[vreadpixel 118 273 name] != "LIGHTSLATEGRAY 1" || [vreadpixel 270 260 name] != "GRAY15 0.24705882370471954"} {
puts "ERROR: Errors in changing View Cube colors."
}
vdump $anImage1
# -------------------------------------
# Transparency
# -------------------------------------
vviewcube -reset
vviewcube -transparency 0.5
if {[vreadpixel 118 273 name] != "GRAY17 0.37254902720451355" || [vreadpixel 270 260 name] != "GRAY48 0.24705882370471954"} {
puts "ERROR: Errors in changing View Cube common transparency."
}
vdump $anImage2
vviewcube -reset
vviewcube -boxtransparency 0.4 -arrowtransparency 0.2
if {[vreadpixel 118 273 name] != "GRAY16 0.5058823823928833" || [vreadpixel 270 260 name] != "GRAY76 0.63921570777893066"} {
puts "ERROR: Errors in changing View Cube separate transparency."
}
vdump $anImage3
# -------------------------------------
# Arrows
# -------------------------------------
vviewcube -reset
vviewcube -arrowangle 30 -arrowlength 30
if {[vreadpixel 270 268 name] != "BLACK 0" || [vreadpixel 291 259 name] != "GRAY48 0.24705882370471954"} {
puts "ERROR: Errors in changing View Cube arrow style."
}
vdump $anImage4
# -------------------------------------
# Font
# -------------------------------------
vviewcube -reset
vviewcube -font "Impact" -fontheight 16
if {[vreadpixel 150 200 name] != "BLACK 0.729411780834198" || [vreadpixel 168 391 name] != "RED 1"} {
puts "ERROR: Errors in changing View Cube font."
}
vdump $anImage5
# -------------------------------------
# Padding
# -------------------------------------
vviewcube -reset
vviewcube -boxpadding 10 -axispadding 20 -arrowpadding 10
if {[vreadpixel 71 263 name] != "BLACK 0" || [vreadpixel 37 266 name] != "BLUE2 1"} {
puts "ERROR: Errors in changing View Cube padding."
}
vdump $anImage6
# -------------------------------------
# Corner radius
# -------------------------------------
vviewcube -reset
vviewcube -cornerradius 0.2
vdump $anImage7
vviewcube -remove
vclear

28
tests/v3d/viewcube/view Normal file
View File

@@ -0,0 +1,28 @@
puts "=================================="
puts "AIS_ViewCube - check view affinity"
puts "=================================="
set anImage1 $imagedir/${casename}_1.png
set anImage2 $imagedir/${casename}_2.png
vclear
vclose ALL
vinit view1
vinit view2
vviewcube -enable
if {[vreadpixel 150 220 name] != "GRAY68 1"} {
puts "ERROR: display of View Cube in view2 fails."
}
vdump $anImage1
vactivate view1
if {[vreadpixel 150 220 name] != "BLACK 0"} {
puts "ERROR: View Cube should not be displayed in view1."
}
vdump $anImage2
vactivate view2
vviewcube -remove

25
tests/v3d/viewcube/view2 Normal file
View File

@@ -0,0 +1,25 @@
puts "=================================="
puts "AIS_ViewCube - check view affinity"
puts "=================================="
set anImage1 $imagedir/${casename}_1.png
set anImage2 $imagedir/${casename}_2.png
vclear
vclose ALL
vinit view1
vviewcube -enable
if {[vreadpixel 150 220 name] != "GRAY68 1"} {
puts "ERROR: display of View Cube in view1 fails."
}
vdump $anImage1
vviewcube -remove
vinit view2
vviewcube -enable
if {[vreadpixel 150 220 name] != "GRAY68 1"} {
puts "ERROR: View Cube should not be displayed in view1."
}
vdump $anImage2
vviewcube -remove