1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00
occt/src/AIS/AIS_Circle.cxx
vpa f751596e46 0024623: Visualization - improve selection mechanism
Redesign of selection mechanism:
- implemented 3-level BVH tree for selection;
- selection now calculates in 3D space;
- intersection tests were moved to SelectMgr_BaseFrustum descendants;
- removed .cdl files in Select3D and .cdl related to selection in MeshVS;
- SelectMgr_ViewerSelectors are now shared between local and global contexts;
- transformations of sensitive entities are now stored in SelectMgr_SelectableObject only. Sensitive entities are independent from transformations, it is applied to SelectMgr_SelectingVolumeManager instance only;
- connected and multiple connected interactive objects are now represented by their child objects only for SelectMgr_SelectionManager;
- if interactive object has child objects, they will be stored as separate objects in SelectMgr_SelectionManager now.
- test cases bugs/vis/bug24623_1, bug24623_2, bug24623_3, bug24623_4 to test performance and memory issues.
2015-04-06 17:27:38 +03:00

265 lines
9.3 KiB
C++

// Created on: 1997-01-21
// Created by: Prestataire Christiane ARMAND
// 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.
#include <AIS_Circle.ixx>
#include <Aspect_TypeOfLine.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_Structure.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <Select3D_SensitiveCircle.hxx>
#include <StdPrs_DeflectionCurve.hxx>
#include <TopoDS.hxx>
#include <Geom_Circle.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GC_MakeArcOfCircle.hxx>
#include <Quantity_Color.hxx>
#include <AIS_GraphicTool.hxx>
//=======================================================================
//function : AIS_Circle
//purpose :
//=======================================================================
AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent):
AIS_InteractiveObject(PrsMgr_TOP_AllView),
myComponent(aComponent),
myUStart(0.),
myUEnd(2*M_PI),
myCircleIsArc(Standard_False),
myIsFilledCircleSens (Standard_False)
{
}
//=======================================================================
//function : AIS_Circle
//purpose :
//=======================================================================
AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& theComponent,
const Standard_Real theUStart,
const Standard_Real theUEnd,
const Standard_Boolean theIsFilledCircleSens)
: AIS_InteractiveObject(PrsMgr_TOP_AllView),
myComponent (theComponent),
myUStart (theUStart),
myUEnd (theUEnd),
myCircleIsArc (Standard_True),
myIsFilledCircleSens (theIsFilledCircleSens)
{
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_Circle::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer /*aMode*/)
{
aPresentation->Clear();
aPresentation->SetDisplayPriority(5);
if (myCircleIsArc) ComputeArc(aPresentation);
else ComputeCircle(aPresentation);
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_Circle::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Geom_Transformation)& aTransformation,
const Handle(Prs3d_Presentation)& aPresentation)
{
// Standard_NotImplemented::Raise("AIS_Circle::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)");
PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_Circle::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer /*aMode*/)
{
if (myCircleIsArc) ComputeArcSelection(aSelection);
else ComputeCircleSelection(aSelection);
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_Circle::SetColor(const Quantity_NameOfColor aCol)
{
SetColor(Quantity_Color(aCol));
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_Circle::SetColor(const Quantity_Color &aCol)
{
hasOwnColor=Standard_True;
myOwnColor=aCol;
Standard_Real WW = HasWidth() ? myOwnWidth :
myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) :
1.;
if (!myDrawer->HasOwnLineAspect ())
myDrawer->SetLineAspect (new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
else
myDrawer->LineAspect()->SetColor(aCol);
}
//=======================================================================
//function : SetWidth
//purpose :
//=======================================================================
void AIS_Circle::SetWidth(const Standard_Real aValue)
{
myOwnWidth=aValue;
if (!myDrawer->HasOwnLineAspect ()) {
Quantity_Color CC = Quantity_NOC_YELLOW;
if( HasColor() ) CC = myOwnColor;
else if(myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC);
myDrawer->SetLineAspect (new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,aValue));
} else
myDrawer->LineAspect()->SetWidth(aValue);
}
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_Circle::UnsetColor()
{
hasOwnColor = Standard_False;
Handle(Prs3d_LineAspect) NullAsp;
if (!HasWidth()) myDrawer->SetLineAspect(NullAsp);
else{
Quantity_Color CC = Quantity_NOC_YELLOW;;
if( HasColor() ) CC = myOwnColor;
else if (myDrawer->HasLink()) AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
myDrawer->LineAspect()->SetColor(CC);
myOwnColor = CC;
}
}
//=======================================================================
//function : UnsetWidth
//purpose :
//=======================================================================
void AIS_Circle::UnsetWidth()
{
Handle(Prs3d_LineAspect) NullAsp;
if (!HasColor()) myDrawer->SetLineAspect(NullAsp);
else{
Standard_Real WW = myDrawer->HasLink() ? AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line) : 1.;
myDrawer->LineAspect()->SetWidth(WW);
myOwnWidth = WW;
}
}
//=======================================================================
//function : ComputeCircle
//purpose :
//=======================================================================
void AIS_Circle::ComputeCircle( const Handle(Prs3d_Presentation)& aPresentation)
{
GeomAdaptor_Curve curv(myComponent);
Standard_Real prevdev = myDrawer->DeviationCoefficient();
myDrawer->SetDeviationCoefficient(1.e-5);
StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer);
myDrawer->SetDeviationCoefficient(prevdev);
}
//=======================================================================
//function : ComputeArc
//purpose :
//=======================================================================
void AIS_Circle::ComputeArc( const Handle(Prs3d_Presentation)& aPresentation)
{
GeomAdaptor_Curve curv(myComponent,myUStart,myUEnd);
Standard_Real prevdev = myDrawer->DeviationCoefficient();
myDrawer->SetDeviationCoefficient(1.e-5);
StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer);
myDrawer->SetDeviationCoefficient(prevdev);
}
//=======================================================================
//function : ComputeCircleSelection
//purpose :
//=======================================================================
void AIS_Circle::ComputeCircleSelection(const Handle(SelectMgr_Selection)& aSelection)
{
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle (eown,
myComponent,
myIsFilledCircleSens);
aSelection->Add(seg);
}
//=======================================================================
//function : ComputeArcSelection
//purpose :
//=======================================================================
void AIS_Circle::ComputeArcSelection(const Handle(SelectMgr_Selection)& aSelection)
{
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle (eown,
myComponent,
myUStart, myUEnd,
myIsFilledCircleSens);
aSelection->Add(seg);
}
//=======================================================================
//function : Compute
//purpose : to avoid warning
//=======================================================================
void AIS_Circle::Compute(const Handle(Prs3d_Projector)&,
const Handle(Prs3d_Presentation)&)
{
}