1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

Compare commits

..

2 Commits

Author SHA1 Message Date
alex
ba382e61db temporary patch to avoid deactivate selection on children after the parent's hiding 2019-10-15 14:59:45 +03:00
nds
05ac0c7d75 0030922: Visualization - OpenGl_Text wrong local transformation if text has not own attach point
(cherry picked from commit d149bbcbaf7d237425b574a1977acb07db299bea)
(cherry picked from commit 95a4927b5b2b9310de6ebe36f0fe6523cebe52c6)
(cherry picked from commit f414985732fb8084363d543e65fc4d7232e22488)
2019-10-10 08:49:23 +03:00
10 changed files with 37 additions and 56 deletions

View File

@@ -41,6 +41,7 @@ AIS_TextLabel::AIS_TextLabel()
myFont ("Courier"),
myFontAspect (Font_FA_Regular),
myHasOrientation3D (Standard_False),
myHasOwnAnchorPoint (Standard_True),
myHasFlipping (Standard_False)
{
myDrawer->SetTextAspect (new Prs3d_TextAspect());
@@ -308,7 +309,12 @@ void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePr
gp_Ax2 anOrientation = myOrientation3D;
anOrientation.SetLocation (aPosition);
Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePrs), anAsp, myText, myOrientation3D, !myHasFlipping);
Standard_Boolean aHasOwnAnchor = HasOwnAnchorPoint();
if (myHasFlipping)
aHasOwnAnchor = Standard_False; // always not using own anchor if flipping
Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePrs), anAsp, myText, myOrientation3D, aHasOwnAnchor);
if (myHasFlipping && isInit)
{
Prs3d_Root::CurrentGroup (thePrs)->SetFlippingOptions (Standard_False, gp_Ax2());

View File

@@ -90,6 +90,12 @@ public:
Standard_EXPORT Standard_Boolean HasFlipping() const;
//! Returns flag if text uses position as point of attach
Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchorPoint; }
//! Set flag if text uses position as point of attach
void SetOwnAnchorPoint (const Standard_Boolean theOwnAnchorPoint) { myHasOwnAnchorPoint = theOwnAnchorPoint; }
//! Define the display type of the text.
//!
//! TODT_NORMAL Default display. Text only.
@@ -121,6 +127,7 @@ protected:
Font_FontAspect myFontAspect;
gp_Ax2 myOrientation3D;
Standard_Boolean myHasOrientation3D;
Standard_Boolean myHasOwnAnchorPoint;
Standard_Boolean myHasFlipping;
public:

View File

@@ -426,6 +426,12 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
{
OpenGl_Mat4d aCurrentWorldViewMat;
aCurrentWorldViewMat.Convert (theCtx->WorldViewState.Current());
// apply local transformation
OpenGl_Mat4d aModelWorld;
aModelWorld.Convert (theCtx->ModelWorldState.Current());
aCurrentWorldViewMat = aCurrentWorldViewMat * aModelWorld;
theCtx->WorldViewState.SetCurrent<Standard_Real> (aCurrentWorldViewMat * aModViewMat);
}
else

View File

@@ -97,25 +97,9 @@ namespace
return aPoly;
}
//! Add new solid
virtual void AddSolid() Standard_OVERRIDE
{
Handle(Poly_Triangulation) aCurrentTri = GetTriangulation();
myTriangulationList.Append(aCurrentTri);
myNodes.Clear();
myTriangles.Clear();
}
NCollection_Sequence<Handle(Poly_Triangulation)> GetTriangulationList()
{
return myTriangulationList;
}
private:
NCollection_Vector<gp_XYZ> myNodes;
NCollection_Vector<Poly_Triangle> myTriangles;
NCollection_Sequence<Handle(Poly_Triangulation)> myTriangulationList;
};
}
@@ -134,17 +118,6 @@ Handle(Poly_Triangulation) RWStl::ReadFile (const Standard_CString theFile,
return aReader.GetTriangulation();
}
//=============================================================================
//function : ReadFile
//purpose :
//=============================================================================
void RWStl::ReadFile(const Standard_CString theFile, NCollection_Sequence<Handle(Poly_Triangulation)>& theTriangList)
{
Reader aReader;
aReader.Read(theFile, Handle(Message_ProgressIndicator)(), true);
theTriangList = aReader.GetTriangulationList();
}
//=============================================================================
//function : ReadFile
//purpose :

View File

@@ -50,8 +50,6 @@ public:
Standard_EXPORT static Handle(Poly_Triangulation) ReadFile (const Standard_CString theFile,
const Handle(Message_ProgressIndicator)& aProgInd = Handle(Message_ProgressIndicator)());
Standard_EXPORT static void ReadFile(const Standard_CString theFile, NCollection_Sequence<Handle(Poly_Triangulation)>& theTriangList);
//! Read triangulation from a binary STL file
//! In case of error, returns Null handle.
Standard_EXPORT static Handle(Poly_Triangulation) ReadBinary (const OSD_Path& thePath,

View File

@@ -126,8 +126,7 @@ namespace
//==============================================================================
Standard_Boolean RWStl_Reader::Read (const char* theFile,
const Handle(Message_ProgressIndicator)& theProgress,
bool IsMultiSolid)
const Handle(Message_ProgressIndicator)& theProgress)
{
std::filebuf aBuf;
OSD_OpenStream (aBuf, theFile, std::ios::in | std::ios::binary);
@@ -166,8 +165,6 @@ Standard_Boolean RWStl_Reader::Read (const char* theFile,
}
}
aStream >> std::ws; // skip any white spaces
if (IsMultiSolid)
AddSolid();
}
return ! aStream.fail();
}

View File

@@ -39,8 +39,7 @@ public:
//! Format is recognized automatically by analysis of the file header.
//! Returns true if success, false on error or user break.
Standard_EXPORT Standard_Boolean Read (const char* theFile,
const Handle(Message_ProgressIndicator)& theProgress,
bool IsMultiSolid = false);
const Handle(Message_ProgressIndicator)& theProgress);
//! Guess whether the stream is an Ascii STL file, by analysis of the first bytes (~200).
//! The function attempts to put back the read symbols to the stream which thus must support ungetc().
@@ -75,8 +74,6 @@ public:
//! Should create new triangle built on specified nodes in the target model.
virtual void AddTriangle (Standard_Integer theN1, Standard_Integer theN2, Standard_Integer theN3) = 0;
virtual void AddSolid() = 0;
};
#endif

View File

@@ -185,9 +185,12 @@ void SelectMgr_SelectionManager::Activate (const Handle(SelectMgr_SelectableObje
void SelectMgr_SelectionManager::Deactivate (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode)
{
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
if (theObject->ToPropagateVisualState())
{
Deactivate (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode);
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter(theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
{
Deactivate(Handle(SelectMgr_SelectableObject)::DownCast(anChildrenIter.Value()), theMode);
}
}
if (!theObject->HasOwnPresentations())
{

View File

@@ -2542,6 +2542,15 @@ static int VDrawText (Draw_Interpretor& theDI,
{
aTextPrs->SetFlipping (Standard_True);
}
else if (aParam == "-ownanchor")
{
if (++anArgIt >= theArgsNb)
{
std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
return 1;
}
aTextPrs->SetOwnAnchorPoint (Draw::Atoi (theArgVec[anArgIt]) == 1);
}
else if (aParam == "-disptype"
|| aParam == "-displaytype")
{
@@ -6459,6 +6468,7 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
"\n\t\t: [-noupdate]"
"\n\t\t: [-plane NormX NormY NormZ DirX DirY DirZ]"
"\n\t\t: [-flipping]"
"\n\t\t: [-ownanchor {0|1}=1]"
"\n\t\t: Display text label at specified position.",
__FILE__, VDrawText, group);

View File

@@ -411,22 +411,6 @@ static Standard_Integer ReadObj (Draw_Interpretor& theDI,
{
aFilePath = theArgVec[anArgIter];
}
else if (theArgc == 4 && strcmp("multi", theArgv[3]) == 0)
{
NCollection_Sequence<Handle(Poly_Triangulation)> theTriangList;
RWStl::ReadFile(theArgv[2], theTriangList);
BRep_Builder aB;
TopoDS_Compound aCmp;
aB.MakeCompound(aCmp);
for (int i = 1; i <= theTriangList.Length(); i++)
{
TopoDS_Face aFace;
aB.MakeFace(aFace);
aB.UpdateFace(aFace, theTriangList(i));
aB.Add(aCmp, aFace);
}
DBRep::Set(theArgv[1], aCmp);
}
else
{
std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n";