GDD & CCAR:

Improve performance of OnColor()
This commit is contained in:
gdd 2011-01-05 16:29:52 +00:00
parent 08ccaeae90
commit d02241355e

View File

@ -340,29 +340,35 @@ void GEOMToolsGUI::OnColor()
if ( c.isValid() ) { if ( c.isValid() ) {
SUIT_OverrideCursor(); SUIT_OverrideCursor();
aColor = Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB ); aColor = Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
Handle (AIS_InteractiveContext) ic = vm->getAISContext();
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
io = GEOMBase::GetAIS( It.Value(), true ); io = GEOMBase::GetAIS( It.Value(), true );
if ( !io.IsNull() ) { if ( !io.IsNull() ) {
// Set color for a point
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> if ( io->IsKind( STANDARD_TYPE(AIS_Shape) ) ) {
( window->getViewManager()->getViewModel() ); TopoDS_Shape theShape = Handle(AIS_Shape)::DownCast( io )->Shape();
Handle (AIS_InteractiveContext) ic = vm->getAISContext(); if (theShape.ShapeType() == TopAbs_VERTEX) {
Handle(AIS_Drawer) aCurDrawer = io->Attributes(); // Set color for a point
Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
Quantity_Color aCurColor; Handle(AIS_Drawer) aCurDrawer = io->Attributes();
Standard_Real aCurScale; Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
Aspect_TypeOfMarker aCurTypeOfMarker; Quantity_Color aCurColor;
aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale ); Standard_Real aCurScale;
if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) { Aspect_TypeOfMarker aCurTypeOfMarker;
aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aCurTypeOfMarker, aColor, aCurScale)); aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) {
aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aCurTypeOfMarker, aColor, aCurScale));
}
else {
Standard_Integer aWidth, aHeight;
aCurPointAspect->GetTextureSize( aWidth, aHeight );
Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aColor, 1, aWidth, aHeight, aTexture));
}
ic->SetLocalAttributes(io, aCurDrawer, Standard_False);
}
} }
else {
Standard_Integer aWidth, aHeight;
aCurPointAspect->GetTextureSize( aWidth, aHeight );
Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aColor, 1, aWidth, aHeight, aTexture));
}
ic->SetLocalAttributes(io, aCurDrawer);
io->SetColor( aColor ); io->SetColor( aColor );
if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
@ -384,6 +390,7 @@ void GEOMToolsGUI::OnColor()
anObject->SetAutoColor( false ); anObject->SetAutoColor( false );
} }
} // for } // for
ic->UpdateCurrentViewer();
GeometryGUI::Modified(); GeometryGUI::Modified();
} // if c.isValid() } // if c.isValid()
} // first IO is not null } // first IO is not null