mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-29 23:30:33 +05:00
Corrective patch for bring-to-front and auto-selection of position on compound shape
This commit is contained in:
parent
c8f243de05
commit
a2a6f8464c
@ -87,8 +87,6 @@ SALOME_Prs* GEOMGUI_AnnotationMgr::CreatePresentation( const GEOMGUI_AnnotationA
|
|||||||
|
|
||||||
aPresentation->SetIsScreenFixed( theProperty.IsScreenFixed );
|
aPresentation->SetIsScreenFixed( theProperty.IsScreenFixed );
|
||||||
|
|
||||||
setDisplayProperties( aPresentation, aView, getEntry( theObject ).c_str() );
|
|
||||||
|
|
||||||
TopoDS_Shape aShape = GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObject );
|
TopoDS_Shape aShape = GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObject );
|
||||||
if ( !aShape.IsNull() ) {
|
if ( !aShape.IsNull() ) {
|
||||||
|
|
||||||
@ -111,6 +109,8 @@ SALOME_Prs* GEOMGUI_AnnotationMgr::CreatePresentation( const GEOMGUI_AnnotationA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setDisplayProperties( aPresentation, aView, getEntry( theObject ).c_str() );
|
||||||
|
|
||||||
// add Prs to preview
|
// add Prs to preview
|
||||||
SUIT_ViewWindow* vw = getApplication()->desktop()->activeWindow();
|
SUIT_ViewWindow* vw = getApplication()->desktop()->activeWindow();
|
||||||
SOCC_Prs* aPrs =
|
SOCC_Prs* aPrs =
|
||||||
@ -412,8 +412,6 @@ void GEOMGUI_AnnotationMgr::UpdateVisibleAnnotations( const QString& theEntry, S
|
|||||||
if ( aPresentation.IsNull() )
|
if ( aPresentation.IsNull() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
setDisplayProperties( aPresentation, aView, theEntry );
|
|
||||||
|
|
||||||
if ( !aShape.IsNull() ) {
|
if ( !aShape.IsNull() ) {
|
||||||
|
|
||||||
gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
|
gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
|
||||||
@ -430,6 +428,8 @@ void GEOMGUI_AnnotationMgr::UpdateVisibleAnnotations( const QString& theEntry, S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setDisplayProperties( aPresentation, aView, theEntry );
|
||||||
|
|
||||||
aView->getAISContext()->Redisplay( aPresentation );
|
aView->getAISContext()->Redisplay( aPresentation );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -503,12 +503,11 @@ void MeasureGUI_AnnotationDlg::SelectionIntoArgument()
|
|||||||
TopoDS_Shape aShape;
|
TopoDS_Shape aShape;
|
||||||
GEOMBase::GetShape( myShape.get(), aShape );
|
GEOMBase::GetShape( myShape.get(), aShape );
|
||||||
|
|
||||||
if ( !getPickedPoint( anAttachPoint, aShape ) ) {
|
hasAttachPoint = getPickedPoint( anAttachPoint, aShape );
|
||||||
|
if ( !hasAttachPoint ) {
|
||||||
|
|
||||||
anAttachPoint = getAttachPoint( aShape );
|
anAttachPoint = getAttachPoint( aShape, hasAttachPoint );
|
||||||
}
|
}
|
||||||
|
|
||||||
hasAttachPoint = true;
|
|
||||||
}
|
}
|
||||||
} else if ( myEditCurrentArgument == mySubShapeName ) {
|
} else if ( myEditCurrentArgument == mySubShapeName ) {
|
||||||
if ( !myShape->_is_nil() ) {
|
if ( !myShape->_is_nil() ) {
|
||||||
@ -537,11 +536,11 @@ void MeasureGUI_AnnotationDlg::SelectionIntoArgument()
|
|||||||
TopoDS_Shape aShape;
|
TopoDS_Shape aShape;
|
||||||
GEOMBase::GetShape( myShape.get(), aShape );
|
GEOMBase::GetShape( myShape.get(), aShape );
|
||||||
|
|
||||||
if ( !getPickedPoint( anAttachPoint, aSubShape ) ) {
|
hasAttachPoint = getPickedPoint( anAttachPoint, aSubShape );
|
||||||
|
if ( !hasAttachPoint ) {
|
||||||
|
|
||||||
anAttachPoint = getAttachPoint( aSubShape );
|
anAttachPoint = getAttachPoint( aSubShape, hasAttachPoint );
|
||||||
}
|
}
|
||||||
hasAttachPoint = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -739,6 +738,11 @@ bool MeasureGUI_AnnotationDlg::isValid( QString& theMessage )
|
|||||||
//RETURN_WITH_MSG( CORBA::is_nil( myShape ), tr( "NO_FIELD" ) )
|
//RETURN_WITH_MSG( CORBA::is_nil( myShape ), tr( "NO_FIELD" ) )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( myIsCreation ) {
|
||||||
|
RETURN_WITH_MSG( !myIsPositionDefined, tr( "NO_POSITION" ) )
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -869,8 +873,9 @@ bool MeasureGUI_AnnotationDlg::getPickedPoint( gp_Pnt& thePnt, const TopoDS_Shap
|
|||||||
{
|
{
|
||||||
if ( theShape.ShapeType() == TopAbs_VERTEX )
|
if ( theShape.ShapeType() == TopAbs_VERTEX )
|
||||||
{
|
{
|
||||||
thePnt = getAttachPoint( theShape );
|
bool isOk = false;
|
||||||
return true;
|
thePnt = getAttachPoint( theShape, isOk );
|
||||||
|
return isOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SUIT_ViewWindow* anActiveView = GEOMBase_Helper::getActiveView();
|
const SUIT_ViewWindow* anActiveView = GEOMBase_Helper::getActiveView();
|
||||||
@ -902,80 +907,55 @@ bool MeasureGUI_AnnotationDlg::getPickedPoint( gp_Pnt& thePnt, const TopoDS_Shap
|
|||||||
// function : getAttachPoint
|
// function : getAttachPoint
|
||||||
// purpose : computes default attachment point on the shape
|
// purpose : computes default attachment point on the shape
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
gp_Pnt MeasureGUI_AnnotationDlg::getAttachPoint( const TopoDS_Shape& theShape )
|
gp_Pnt MeasureGUI_AnnotationDlg::getAttachPoint( const TopoDS_Shape& theShape, bool& theIsOk )
|
||||||
{
|
{
|
||||||
TopoDS_Shape aAttachShape;
|
gp_Pnt aPnt( 0.0, 0.0, 0.0 );
|
||||||
if ( theShape.ShapeType() == TopAbs_COMPOUND )
|
theIsOk = true;
|
||||||
{
|
if ( theShape.ShapeType() == TopAbs_COMPSOLID
|
||||||
QStack< NCollection_Handle<TopoDS_Iterator> > aItStack;
|
|| theShape.ShapeType() == TopAbs_SOLID
|
||||||
aItStack.push( NCollection_Handle<TopoDS_Iterator>( new TopoDS_Iterator( theShape ) ) );
|
|| theShape.ShapeType() == TopAbs_SHELL )
|
||||||
while ( aAttachShape.IsNull() && !aItStack.empty() )
|
|
||||||
{
|
|
||||||
NCollection_Handle<TopoDS_Iterator> anIt = aItStack.top();
|
|
||||||
if ( !anIt->More() )
|
|
||||||
{
|
|
||||||
aItStack.pop();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const TopoDS_Shape& aShape = anIt->Value();
|
|
||||||
if ( aShape.ShapeType() != TopAbs_COMPSOLID )
|
|
||||||
{
|
|
||||||
aAttachShape = aShape;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aItStack.push( NCollection_Handle<TopoDS_Iterator>( new TopoDS_Iterator( aShape ) ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aAttachShape = theShape;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( aAttachShape.ShapeType() == TopAbs_COMPSOLID
|
|
||||||
|| aAttachShape.ShapeType() == TopAbs_SOLID
|
|
||||||
|| aAttachShape.ShapeType() == TopAbs_SHELL )
|
|
||||||
{
|
{
|
||||||
Bnd_Box aBox;
|
Bnd_Box aBox;
|
||||||
BRepBndLib::Add( aAttachShape, aBox );
|
BRepBndLib::Add( theShape, aBox );
|
||||||
const gp_Pnt aMin = aBox.CornerMin();
|
const gp_Pnt aMin = aBox.CornerMin();
|
||||||
const gp_Pnt aMax = aBox.CornerMax();
|
const gp_Pnt aMax = aBox.CornerMax();
|
||||||
return gp_Pnt( (aMin.X() + aMax.X()) / 2.0,
|
aPnt = gp_Pnt( (aMin.X() + aMax.X()) / 2.0,
|
||||||
(aMin.Y() + aMax.Y()) / 2.0,
|
(aMin.Y() + aMax.Y()) / 2.0,
|
||||||
(aMin.Z() + aMax.Z()) / 2.0 );
|
(aMin.Z() + aMax.Z()) / 2.0 );
|
||||||
}
|
}
|
||||||
else if ( aAttachShape.ShapeType() == TopAbs_FACE )
|
else if ( theShape.ShapeType() == TopAbs_FACE )
|
||||||
{
|
{
|
||||||
BRepAdaptor_Surface aFace( TopoDS::Face( aAttachShape ) );
|
BRepAdaptor_Surface aFace( TopoDS::Face( theShape ) );
|
||||||
const Standard_Real aU1 = aFace.FirstUParameter();
|
const Standard_Real aU1 = aFace.FirstUParameter();
|
||||||
const Standard_Real aU2 = aFace.LastUParameter();
|
const Standard_Real aU2 = aFace.LastUParameter();
|
||||||
const Standard_Real aV1 = aFace.FirstVParameter();
|
const Standard_Real aV1 = aFace.FirstVParameter();
|
||||||
const Standard_Real aV2 = aFace.LastVParameter();
|
const Standard_Real aV2 = aFace.LastVParameter();
|
||||||
return aFace.Value( ( aU1 + aU2 ) / 2.0, ( aV1 + aV2 ) / 2.0 );
|
aPnt = aFace.Value( ( aU1 + aU2 ) / 2.0, ( aV1 + aV2 ) / 2.0 );
|
||||||
}
|
}
|
||||||
else if ( aAttachShape.ShapeType() == TopAbs_WIRE )
|
else if ( theShape.ShapeType() == TopAbs_WIRE )
|
||||||
{
|
{
|
||||||
BRepAdaptor_CompCurve aWire( TopoDS::Wire( aAttachShape ) );
|
BRepAdaptor_CompCurve aWire( TopoDS::Wire( theShape ) );
|
||||||
const Standard_Real aP1 = aWire.FirstParameter();
|
const Standard_Real aP1 = aWire.FirstParameter();
|
||||||
const Standard_Real aP2 = aWire.LastParameter();
|
const Standard_Real aP2 = aWire.LastParameter();
|
||||||
return aWire.Value( ( aP1 + aP2 ) / 2.0 );
|
aPnt = aWire.Value( ( aP1 + aP2 ) / 2.0 );
|
||||||
}
|
}
|
||||||
else if ( aAttachShape.ShapeType() == TopAbs_EDGE )
|
else if ( theShape.ShapeType() == TopAbs_EDGE )
|
||||||
{
|
{
|
||||||
BRepAdaptor_Curve aEdge( TopoDS::Edge( aAttachShape ) );
|
BRepAdaptor_Curve aEdge( TopoDS::Edge( theShape ) );
|
||||||
const Standard_Real aP1 = aEdge.FirstParameter();
|
const Standard_Real aP1 = aEdge.FirstParameter();
|
||||||
const Standard_Real aP2 = aEdge.LastParameter();
|
const Standard_Real aP2 = aEdge.LastParameter();
|
||||||
return aEdge.Value( ( aP1 + aP2 ) / 2.0 );
|
aPnt = aEdge.Value( ( aP1 + aP2 ) / 2.0 );
|
||||||
}
|
}
|
||||||
else if ( aAttachShape.ShapeType() == TopAbs_VERTEX )
|
else if ( theShape.ShapeType() == TopAbs_VERTEX )
|
||||||
{
|
{
|
||||||
return BRep_Tool::Pnt( TopoDS::Vertex( aAttachShape ) );
|
aPnt = BRep_Tool::Pnt( TopoDS::Vertex( theShape ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
theIsOk = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return gp_Pnt( 0.0, 0.0, 0.0 );
|
return aPnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
|
@ -97,7 +97,7 @@ private:
|
|||||||
TopAbs_ShapeEnum getShapeType() const;
|
TopAbs_ShapeEnum getShapeType() const;
|
||||||
|
|
||||||
bool getPickedPoint( gp_Pnt& thePnt, const TopoDS_Shape& theShape );
|
bool getPickedPoint( gp_Pnt& thePnt, const TopoDS_Shape& theShape );
|
||||||
gp_Pnt getAttachPoint( const TopoDS_Shape& theShape );
|
gp_Pnt getAttachPoint( const TopoDS_Shape& theShape, bool& theIsOk );
|
||||||
gp_Pnt getDefaultPosition( const gp_Pnt& theAttach );
|
gp_Pnt getDefaultPosition( const gp_Pnt& theAttach );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user