CCAR: problem with an endless loop in getAIS

This commit is contained in:
caremoli 2011-01-05 14:29:52 +00:00
parent 10e23ee67f
commit 08ccaeae90
2 changed files with 69 additions and 66 deletions

View File

@ -388,23 +388,26 @@ Handle(AIS_InteractiveObject) GEOMBase::GetAIS( const Handle(SALOME_InteractiveO
foreach ( SUIT_ViewWindow* view, views ) { foreach ( SUIT_ViewWindow* view, views ) {
if ( view && view->getViewManager()->getType() == OCCViewer_Viewer::Type() ) { if ( view && view->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
Handle(AIS_InteractiveContext) anIC = ((OCCViewer_Viewer*)view->getViewManager()->getViewModel())->getAISContext(); Handle(AIS_InteractiveContext) anIC = ((OCCViewer_Viewer*)view->getViewManager()->getViewModel())->getAISContext();
AIS_ListOfInteractive displayed; AIS_ListOfInteractive displayed;
anIC->DisplayedObjects( displayed ); anIC->DisplayedObjects( displayed );
anIC->ObjectsInCollector( displayed ); anIC->ObjectsInCollector( displayed );
AIS_ListIteratorOfListOfInteractive it( displayed ); AIS_ListIteratorOfListOfInteractive it( displayed );
while ( it.More() && aisObject.IsNull() ) { for ( ; it.More(); it.Next() ){
if ( onlyGeom && !it.Value()->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) if ( onlyGeom && !it.Value()->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) )
continue; continue;
Handle(SALOME_InteractiveObject) obj = Handle(SALOME_InteractiveObject) obj =
Handle(SALOME_InteractiveObject)::DownCast( it.Value()->GetOwner() ); Handle(SALOME_InteractiveObject)::DownCast( it.Value()->GetOwner() );
if ( !obj.IsNull() && obj->isSame( IO ) ) if ( !obj.IsNull() && obj->isSame( IO ) )
aisObject = it.Value(); {
} aisObject = it.Value();
break;
}
}
} }
if ( !aisObject.IsNull() ) break; if ( !aisObject.IsNull() ) break;
} }
@ -438,7 +441,7 @@ QStringList GEOMBase::ConvertListOfIOInListOfIOR( const SALOME_ListIO& IObjects
for ( ; it.More(); it.Next() ) { for ( ; it.More(); it.Next() ) {
GEOM::GEOM_Object_var geomObj = ConvertIOinGEOMObject( it.Value() ); GEOM::GEOM_Object_var geomObj = ConvertIOinGEOMObject( it.Value() );
if ( !CORBA::is_nil( geomObj ) ) if ( !CORBA::is_nil( geomObj ) )
iors.append( GetIORFromObject( geomObj ) ); iors.append( GetIORFromObject( geomObj ) );
} }
} }
return iors; return iors;
@ -460,8 +463,8 @@ GEOM::GEOM_Object_ptr GEOMBase::ConvertIOinGEOMObject( const Handle(SALOME_Inter
_PTR(SObject) obj( studyDS->FindObjectID( IO->getEntry() ) ); _PTR(SObject) obj( studyDS->FindObjectID( IO->getEntry() ) );
if ( obj ) { if ( obj ) {
CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( obj ); CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( obj );
if ( !CORBA::is_nil( corbaObj ) ) if ( !CORBA::is_nil( corbaObj ) )
object = GEOM::GEOM_Object::_narrow( corbaObj ); object = GEOM::GEOM_Object::_narrow( corbaObj );
} }
} }
} }
@ -517,20 +520,20 @@ TopoDS_Shape GEOMBase::CreateArrowForLinearEdge( const TopoDS_Shape& shape )
Standard_Real first, last; Standard_Real first, last;
Handle(Geom_Curve) curv = BRep_Tool::Curve( TopoDS::Edge( shape ), first, last ); Handle(Geom_Curve) curv = BRep_Tool::Curve( TopoDS::Edge( shape ), first, last );
if ( curv->IsCN(1) ) { if ( curv->IsCN(1) ) {
const Standard_Real param = ( first+last ) / 2.0; const Standard_Real param = ( first+last ) / 2.0;
gp_Pnt middleParamPoint; gp_Pnt middleParamPoint;
gp_Vec V1; gp_Vec V1;
curv->D1( param, middleParamPoint, V1 ); curv->D1( param, middleParamPoint, V1 );
if ( V1.Magnitude() > Precision::Confusion() ) { if ( V1.Magnitude() > Precision::Confusion() ) {
/* Topology orientation not geom orientation */ /* Topology orientation not geom orientation */
if ( shape.Orientation() == TopAbs_REVERSED ) if ( shape.Orientation() == TopAbs_REVERSED )
V1 *= -1.0; V1 *= -1.0;
gp_Ax2 anAxis( middleParamPoint, gp_Dir( V1 ) ); gp_Ax2 anAxis( middleParamPoint, gp_Dir( V1 ) );
const Standard_Real radius1 = aHeight / 5.0; const Standard_Real radius1 = aHeight / 5.0;
if ( radius1 > 10.0 * Precision::Confusion() && aHeight > 10.0 * Precision::Confusion() ) if ( radius1 > 10.0 * Precision::Confusion() && aHeight > 10.0 * Precision::Confusion() )
ArrowCone = BRepPrimAPI_MakeCone( anAxis, radius1, 0.0, aHeight ).Shape(); ArrowCone = BRepPrimAPI_MakeCone( anAxis, radius1, 0.0, aHeight ).Shape();
} }
} }
} }
catch ( Standard_Failure ) { catch ( Standard_Failure ) {

View File

@ -325,7 +325,7 @@ void GEOMToolsGUI::OnColor()
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
aView->SetColor( It.Value(), c ); aView->SetColor( It.Value(), c );
} }
GeometryGUI::Modified(); GeometryGUI::Modified();
} }
} // if ( isVTK ) } // if ( isVTK )
else if ( isOCC ) { else if ( isOCC ) {
@ -383,8 +383,8 @@ void GEOMToolsGUI::OnColor()
anObject->SetColor( aSColor ); anObject->SetColor( aSColor );
anObject->SetAutoColor( false ); anObject->SetAutoColor( false );
} }
GeometryGUI::Modified(); } // for
} GeometryGUI::Modified();
} // if c.isValid() } // if c.isValid()
} // first IO is not null } // first IO is not null
} // if ( isOCC ) } // if ( isOCC )
@ -506,40 +506,40 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType )
int newNbVIso = -1; int newNbVIso = -1;
if ( actionType == SHOWDLG ) { if ( actionType == SHOWDLG ) {
GEOMToolsGUI_NbIsosDlg * NbIsosDlg = GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() ); new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
NbIsosDlg->setU( UIso ); NbIsosDlg->setU( UIso );
NbIsosDlg->setV( VIso ); NbIsosDlg->setV( VIso );
if ( NbIsosDlg->exec() ) { if ( NbIsosDlg->exec() ) {
SUIT_OverrideCursor(); SUIT_OverrideCursor();
newNbUIso = NbIsosDlg->getU(); newNbUIso = NbIsosDlg->getU();
newNbVIso = NbIsosDlg->getV(); newNbVIso = NbIsosDlg->getV();
} }
} }
else if ( actionType == INCR || actionType == DECR ) { else if ( actionType == INCR || actionType == DECR ) {
int delta = 1; int delta = 1;
if (actionType == DECR) if (actionType == DECR)
delta = -1; delta = -1;
newNbUIso = UIso + delta; newNbUIso = UIso + delta;
newNbVIso = VIso + delta; newNbVIso = VIso + delta;
if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 ) if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 )
return; return;
} }
for(; ic->MoreCurrent(); ic->NextCurrent()) { for(; ic->MoreCurrent(); ic->NextCurrent()) {
CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
Handle(AIS_Drawer) CurDrawer = CurObject->Attributes(); Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , newNbUIso) ); CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , newNbUIso) );
CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , newNbVIso) ); CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , newNbVIso) );
ic->SetLocalAttributes(CurObject, CurDrawer); ic->SetLocalAttributes(CurObject, CurDrawer);
ic->Redisplay(CurObject); ic->Redisplay(CurObject);
} }
} }
GeometryGUI::Modified(); GeometryGUI::Modified();
@ -599,35 +599,35 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType )
if ( actionType == SHOWDLG ) { if ( actionType == SHOWDLG ) {
GEOMToolsGUI_NbIsosDlg* NbIsosDlg = GEOMToolsGUI_NbIsosDlg* NbIsosDlg =
new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() ); new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
NbIsosDlg->setU( UIso ); NbIsosDlg->setU( UIso );
NbIsosDlg->setV( VIso ); NbIsosDlg->setV( VIso );
if ( NbIsosDlg->exec() ) { if ( NbIsosDlg->exec() ) {
SUIT_OverrideCursor(); SUIT_OverrideCursor();
newNbUIso = NbIsosDlg->getU(); newNbUIso = NbIsosDlg->getU();
newNbVIso = NbIsosDlg->getV(); newNbVIso = NbIsosDlg->getV();
} }
} }
else if ( actionType == INCR || actionType == DECR ) { else if ( actionType == INCR || actionType == DECR ) {
int delta = 1; int delta = 1;
if (actionType == DECR) if (actionType == DECR)
delta = -1; delta = -1;
newNbUIso = UIso + delta; newNbUIso = UIso + delta;
newNbVIso = VIso + delta; newNbVIso = VIso + delta;
if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 ) if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 )
return; return;
} }
while( anAct!=NULL ) { while( anAct!=NULL ) {
if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)){ if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)){
// There are no casting to needed actor. // There are no casting to needed actor.
int aIsos[2]={newNbUIso,newNbVIso}; int aIsos[2]={newNbUIso,newNbVIso};
anActor->SetNbIsos(aIsos); anActor->SetNbIsos(aIsos);
} }
anAct = aCollection->GetNextActor(); anAct = aCollection->GetNextActor();
} }