1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +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
13 changed files with 88 additions and 205 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

@@ -86,8 +86,7 @@ typedef enum
MT_BoundaryEdge = 4, //!< Boundary edge (related to a single face)
MT_SharedEdge = 5, //!< Shared edge (related to several faces)
MT_WireFrameFace = 6, //!< Wireframe face
MT_ShadedFace = 7, //!< Shaded face
MT_SeamEdge = 8 //!< Seam edge between faces
MT_ShadedFace = 7 //!< Shaded face
} IVtk_MeshType;
//! @enum IVtk_DisplayMode Display modes for 3D shapes

View File

@@ -719,85 +719,6 @@ static Standard_Integer VtkSetDisplayMode (Draw_Interpretor& theDI,
return 0;
}
//================================================================
// Function : VtkSetBoundaryDraw
// Purpose :
// Draw args : ivtksetboundingdraw [name] draw on/off(0,1)
//================================================================
static Standard_Integer VtkSetBoundaryDraw(Draw_Interpretor& theDI,
Standard_Integer theArgNum,
const char** theArgs)
{
// Check viewer
if (!GetInteractor()->IsEnabled())
{
theDI << theArgs[0] << " error: call ivtkinit before\n";
return 1; // TCL_ERROR
}
// Check arguments
if (theArgNum != 2 && theArgNum != 3)
{
theDI << theArgs[0] << " error: expects 1 or 2 arguments\n";
return 1; // TCL_ERROR
}
vtkSmartPointer<vtkActor> anActor;
// Set disp mode for all objects
if (theArgNum == 2)
{
// Get mode
Standard_Integer toDraw = Draw::Atoi(theArgs[1]);
DoubleMapOfActorsAndNames::Iterator anIter(GetMapOfActors());
while (anIter.More())
{
anActor = anIter.Key1();
IVtkTools_ShapeDataSource* aSrc = IVtkTools_ShapeObject::GetShapeSource(anActor);
if (aSrc)
{
IVtkOCC_Shape::Handle anOccShape = aSrc->GetShape();
if (!anOccShape.IsNull())
{
IVtkTools_DisplayModeFilter* aFilter = GetPipeline(anOccShape->GetId())->GetDisplayModeFilter();
aFilter->SetDisplayMode(DM_Shading);
aFilter->SetFaceBoundaryDraw((toDraw == 0)? false : true);
aFilter->Modified();
aFilter->Update();
}
}
anIter.Next();
}
}
// Set disp mode for named object
else
{
Standard_Integer toDraw = atoi(theArgs[2]);
TCollection_AsciiString aName = theArgs[1];
if (GetMapOfActors().IsBound2(aName))
{
anActor = GetMapOfActors().Find2(aName);
vtkSmartPointer<IVtkTools_ShapeDataSource> aSrc = IVtkTools_ShapeObject::GetShapeSource(anActor);
if (aSrc)
{
IVtkOCC_Shape::Handle anOccShape = aSrc->GetShape();
if (!anOccShape.IsNull())
{
IVtkTools_DisplayModeFilter* aFilter = GetPipeline(anOccShape->GetId())->GetDisplayModeFilter();
aFilter->SetDisplayMode(DM_Shading);
aFilter->SetFaceBoundaryDraw((toDraw == 0) ? false : true);
aFilter->Modified();
aFilter->Update();
}
}
}
}
// Redraw window
GetInteractor()->Render();
return 0;
}
//================================================================
// Function : VtkSetSelectionMode
// Purpose :
@@ -1277,13 +1198,6 @@ void IVtkDraw::Commands (Draw_Interpretor& theCommands)
"if name is not defined.",
__FILE__, VtkSetDisplayMode, group);
theCommands.Add("ivtksetboundingdraw",
"ivtksetboundingdraw usage:\n"
"ivtksetboundingdraw [name] draw on/off (0,1)"
"\n\t\t: Sets or unsets boundaries drawing for shading display mode to the object with name 'name' or to all objects"
"if name is not defined.",
__FILE__, VtkSetBoundaryDraw, group);
theCommands.Add("ivtksetselmode",
"ivtksetselmode usage:\n"
" ivtksetselmode [name] mode on/off(0,1)"

View File

@@ -180,19 +180,15 @@ void IVtkOCC_ShapeMesher::addEdges()
TopAbs_FACE,
anEdgesMap);
TopTools_IndexedMapOfShape anEdgesList;
TopExp::MapShapes(GetShapeObj()->GetShape(), TopAbs_EDGE, anEdgesList);
int aNbFaces;
IVtk_MeshType aType;
myEdgesTypes.Clear();
TopTools_IndexedMapOfShape::const_iterator aEdgeIt;
for (aEdgeIt = anEdgesList.cbegin(); aEdgeIt != anEdgesList.cend(); aEdgeIt++)
TopExp_Explorer anEdgeIter (GetShapeObj()->GetShape(), TopAbs_EDGE);
for (; anEdgeIter.More(); anEdgeIter.Next())
{
const TopoDS_Edge& anOcctEdge = TopoDS::Edge (*aEdgeIt);
const TopTools_ListOfShape& aFaceList = anEdgesMap.FindFromKey(anOcctEdge);
aNbFaces = aFaceList.Extent();
const TopoDS_Edge& anOcctEdge = TopoDS::Edge (anEdgeIter.Current());
aNbFaces = anEdgesMap.FindFromKey (anOcctEdge).Extent();
if (aNbFaces == 0)
{
aType = MT_FreeEdge;
@@ -203,21 +199,7 @@ void IVtkOCC_ShapeMesher::addEdges()
}
else
{
bool isSame = false;
TopTools_ListOfShape::const_iterator aFaceIt;
for (aFaceIt = aFaceList.cbegin(); aFaceIt != aFaceList.cend(); aFaceIt++) {
TopExp_Explorer aIt((*aFaceIt), TopAbs_EDGE);
int aCount = 0;
for (; aIt.More(); aIt.Next()) {
if (aIt.Current().IsSame(anOcctEdge))
aCount++;
}
if (aCount == 2) {
isSame = true;
break;
}
}
aType = isSame? MT_SeamEdge : MT_SharedEdge;
aType = MT_SharedEdge;
}
addEdge (anOcctEdge, GetShapeObj()->GetSubShapeId (anOcctEdge), aType);
myEdgesTypes.Bind (anOcctEdge, aType);

View File

@@ -35,8 +35,7 @@ vtkStandardNewMacro(IVtkTools_DisplayModeFilter)
//============================================================================
IVtkTools_DisplayModeFilter::IVtkTools_DisplayModeFilter()
: myDisplayMode (DM_Wireframe),
myDoDisplaySharedVertices (false),
myDrawFaceBoundaries( false )
myDoDisplaySharedVertices (false)
{
// Filter according to values in subshapes types array.
myIdsArrayName = IVtkVTK_ShapeData::ARRNAME_MESH_TYPES();
@@ -48,16 +47,15 @@ IVtkTools_DisplayModeFilter::IVtkTools_DisplayModeFilter()
aTypes.Add (MT_FreeEdge);
aTypes.Add (MT_BoundaryEdge);
aTypes.Add (MT_SharedEdge);
aTypes.Add (MT_SeamEdge);
aTypes.Add (MT_WireFrameFace);
myModesDefinition[DM_Wireframe] = aTypes;
myModesDefinition.Bind (DM_Wireframe, aTypes);
aTypes.Clear();
aTypes.Add (MT_FreeVertex);
aTypes.Add (MT_ShadedFace);
myModesDefinition[DM_Shading] = aTypes;
myModesDefinition.Bind (DM_Shading, aTypes);
}
//============================================================================
@@ -75,7 +73,7 @@ int IVtkTools_DisplayModeFilter::RequestData (vtkInformation *theRequest,
vtkInformationVector **theInputVector,
vtkInformationVector *theOutputVector)
{
SetData (myModesDefinition[myDisplayMode]);
SetData (myModesDefinition.Find (myDisplayMode));
return Superclass::RequestData (theRequest, theInputVector, theOutputVector);
}
@@ -106,20 +104,24 @@ void IVtkTools_DisplayModeFilter::SetDisplaySharedVertices (const bool theDoDisp
if (myDoDisplaySharedVertices != theDoDisplay)
{
myDoDisplaySharedVertices = theDoDisplay;
vtkIdType aVertexType = MT_SharedVertex;
NCollection_DataMap<IVtk_DisplayMode, IVtk_IdTypeMap>::Iterator aModes (myModesDefinition);
NCollection_DataMap<IVtk_DisplayMode, IVtk_IdTypeMap> aNewModes;
IVtk_IdTypeMap aModeTypes;
for (int i = 0; i < 2; i++)
for (; aModes.More(); aModes.Next())
{
aModeTypes = myModesDefinition[i];
if (theDoDisplay && !aModeTypes.Contains(MT_SharedVertex))
aModeTypes = aModes.Value();
if (theDoDisplay && !aModeTypes.Contains(aVertexType))
{
aModeTypes.Add (MT_SharedVertex);
aModeTypes.Add (aVertexType);
}
else if (!theDoDisplay && aModeTypes.Contains (MT_SharedVertex))
else if (!theDoDisplay && aModeTypes.Contains (aVertexType))
{
aModeTypes.Remove (MT_SharedVertex);
aModeTypes.Remove (aVertexType);
}
myModesDefinition[i] = aModeTypes;
aNewModes.Bind (aModes.Key(), aModeTypes);
}
myModesDefinition = aNewModes;
Modified();
}
}
@@ -146,42 +148,3 @@ IVtk_DisplayMode IVtkTools_DisplayModeFilter::GetDisplayMode () const
return myDisplayMode;
}
//============================================================================
// Method: meshTypesForMode
// Purpose:
//============================================================================
const IVtk_IdTypeMap& IVtkTools_DisplayModeFilter::MeshTypesForMode(IVtk_DisplayMode theMode) const
{
return myModesDefinition[theMode];
}
//============================================================================
// Method: setMeshTypesForMode
// Purpose:
//============================================================================
void IVtkTools_DisplayModeFilter::SetMeshTypesForMode(IVtk_DisplayMode theMode, const IVtk_IdTypeMap& theMeshTypes)
{
myModesDefinition[theMode] = theMeshTypes;
Modified();
}
//============================================================================
// Method: SetFaceBoundaryDraw
// Purpose:
//============================================================================
void IVtkTools_DisplayModeFilter::SetFaceBoundaryDraw(bool theToDraw)
{
myDrawFaceBoundaries = theToDraw;
if (theToDraw) {
myModesDefinition[DM_Shading].Add(MT_BoundaryEdge);
myModesDefinition[DM_Shading].Add(MT_SharedEdge);
}
else {
if (myModesDefinition[DM_Shading].Contains(MT_BoundaryEdge))
myModesDefinition[DM_Shading].Remove(MT_BoundaryEdge);
if (myModesDefinition[DM_Shading].Contains(MT_SharedEdge))
myModesDefinition[DM_Shading].Remove(MT_SharedEdge);
}
Modified();
}

View File

@@ -20,15 +20,11 @@
#include <IVtkTools_SubPolyDataFilter.hxx>
#include <NCollection_DataMap.hxx>
#include <array>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // avoid warning C4251: "class needs to have dll-interface..."
#endif
typedef std::array<IVtk_IdTypeMap, 2> IVtk_DisplayModeArray;
//! @class IVtkTools_DisplayModeFilter
//! @brief Cells filter according to the selected display mode by mesh parts types.
//! This filter is used to get parts of a shape according to different
@@ -50,18 +46,6 @@ public:
//! Get current display mode.
IVtk_DisplayMode GetDisplayMode() const;
//! Returns list of displaying mesh element types for the given display mode
const IVtk_IdTypeMap& MeshTypesForMode(IVtk_DisplayMode theMode) const;
//! Set a list of displaying mesh element types for the given display mode
void SetMeshTypesForMode(IVtk_DisplayMode theMode, const IVtk_IdTypeMap& theMeshTypes);
//! Draw Boundary of faces for shading mode
void SetFaceBoundaryDraw(bool theToDraw);
//! Returns True if drawing Boundary of faces for shading mode is defined.
bool FaceBoundaryDraw() const { return myDrawFaceBoundaries; }
protected:
//! Filter cells according to the given set of ids.
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *);
@@ -71,10 +55,9 @@ protected:
protected:
//! Display mode defining mesh types to pass through this filter.
IVtk_DisplayMode myDisplayMode;
IVtk_DisplayModeArray myModesDefinition;
bool myDoDisplaySharedVertices;
bool myDrawFaceBoundaries;
IVtk_DisplayMode myDisplayMode;
NCollection_DataMap<IVtk_DisplayMode, IVtk_IdTypeMap> myModesDefinition;
bool myDoDisplaySharedVertices;
};
#ifdef _MSC_VER

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

@@ -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

@@ -64,6 +64,7 @@ math_GaussLeastSquare.lxx
math_GaussMultipleIntegration.cxx
math_GaussMultipleIntegration.hxx
math_GaussMultipleIntegration.lxx
math_GaussPoints.hxx
math_GaussSetIntegration.cxx
math_GaussSetIntegration.hxx
math_GaussSetIntegration.lxx

View File

@@ -0,0 +1,28 @@
// Copyright (c) 1997-1999 Matra Datavision
// Copyright (c) 1999-2014 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 math_GaussPoints_HeaderFile
#define math_GaussPoints_HeaderFile
#include <math_Vector.hxx>
#include <Standard_Real.hxx>
extern const Standard_Real Point[157];
extern const Standard_Real Weight[157];
math_Vector GPoints(const Standard_Integer Index);
math_Vector GWeights(const Standard_Integer Index);
#endif

View File

@@ -1,19 +0,0 @@
puts "============="
puts "boundary_draw"
puts "============="
puts ""
#######################################################
# Tests boundary draw flag changing in the IVtk view
#######################################################
set anImage1 $imagedir/${casename}_1.png
set anImage2 $imagedir/${casename}_2.png
ivtkinit
box b 1 1 1
ivtkdisplay b
ivtksetboundingdraw 1
ivtkdump $anImage1
ivtksetboundingdraw 0
ivtkdump $anImage2