X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FDisplayGUI%2FDisplayGUI.cxx;h=44a14839c10d3371d9f31d662ed6484b8cbc8658;hb=d2046800b5f3ab6a56c3b9a72766f5d317a235e7;hp=6b62fe2fefc2955ef1ddef99b9065b32a8936603;hpb=392885c1a8d50369708bbe5e6b44033ed8b8ba51;p=modules%2Fgeom.git diff --git a/src/DisplayGUI/DisplayGUI.cxx b/src/DisplayGUI/DisplayGUI.cxx index 6b62fe2fe..44a14839c 100644 --- a/src/DisplayGUI/DisplayGUI.cxx +++ b/src/DisplayGUI/DisplayGUI.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -53,6 +54,9 @@ #include +#include +#include + #include //======================================================================= @@ -123,6 +127,15 @@ bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) Display(); break; } + case 218: // MENU VIEW - VECTORS MODE + { + bool mode = GetVectorMode(); + SetVectorMode(!mode); + getGeometryGUI()->action( 218 )->setText + ( mode == false ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") ); + getGeometryGUI()->menuMgr()->update(); + break; + } case 80311: // POPUP VIEWER - WIREFRAME { ChangeDisplayMode( 0 ); @@ -133,6 +146,11 @@ bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) ChangeDisplayMode( 1 ); break; } + case 80313: // POPUP VIEWER - VECTORS + { + ChangeDisplayMode( 2 ); + break; + } default: { app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); @@ -392,6 +410,65 @@ int DisplayGUI::GetDisplayMode( SUIT_ViewWindow* viewWindow ) return dispMode; } +//===================================================================================== +// function : DisplayGUI::SetVectorsMode() +// purpose : Set vector mode for the viewer +//===================================================================================== +void DisplayGUI::SetVectorMode( const bool mode, SUIT_ViewWindow* viewWindow ) +{ + SUIT_OverrideCursor(); + + if ( !viewWindow ) + viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow(); + if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) { + viewWindow->setCustomData( "VectorsMode", QVariant( mode ) ); + SVTK_ViewWindow* vw = dynamic_cast( viewWindow ); + vtkActorCollection* allActors = vw->getRenderer()->GetActors(); + allActors->InitTraversal(); + while (vtkActor* actor = allActors->GetNextActor()) { + if (actor->GetVisibility()) { // only for visible actors + GEOM_Actor* aGeomActor = 0; + if ( actor->IsA( "GEOM_Actor" ) ) { + aGeomActor = GEOM_Actor::SafeDownCast( actor ); + if ( aGeomActor ) + aGeomActor->SetVectorMode( mode ); + } + } + } + } + else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) { + viewWindow->setCustomData( "VectorsMode", QVariant( mode ) ); + OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer(); + Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); + AIS_ListOfInteractive List; + ic->DisplayedObjects( List ); + AIS_ListOfInteractive List1; + ic->ObjectsInCollector( List1 ); + List.Append( List1 ); + + AIS_ListIteratorOfListOfInteractive ite( List ); + while( ite.More() ) { + if( ite.Value()->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( ite.Value() ); + aSh->SetDisplayVectors(mode); + ic->RecomputePrsOnly(ite.Value()); + } + ite.Next(); + } + } +} + +//===================================================================================== +// function : DisplayGUI::GetVectorMode() +// purpose : Get the "show edge direction" mode of the viewer +//===================================================================================== +int DisplayGUI::GetVectorMode( SUIT_ViewWindow* viewWindow ) +{ + if ( !viewWindow ) + viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow(); + return viewWindow->getCustomData( "VectorsMode" ).toBool(); +} + //===================================================================================== // function : DisplayGUI::InvertDisplayMode() // purpose : Invert display mode ( shadin <-> wireframe ) for the viewer @@ -434,10 +511,18 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow SVTK_Prs* vtkPrs = stvkViewer ? dynamic_cast( stvkViewer->CreatePrs( It.Value()->getEntry() ) ) : 0; if ( vtkPrs && !vtkPrs->IsNull() ) { - if ( mode == 0 ) - aView->ChangeRepresentationToWireframe( vtkPrs->GetObjects() ); - else if ( mode == 1 ) - aView->ChangeRepresentationToSurface( vtkPrs->GetObjects() ); + if ( mode == 0 ) + aView->ChangeRepresentationToWireframe( vtkPrs->GetObjects() ); + else if ( mode == 1 ) + aView->ChangeRepresentationToSurface( vtkPrs->GetObjects() ); + else if ( mode == 2 ) { + vtkActorCollection* anActors = vtkPrs->GetObjects(); + anActors->InitTraversal(); + while (vtkActor* anAct = anActors->GetNextActor()) { + GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(anAct); + aGeomActor->SetVectorMode(!aGeomActor->GetVectorMode()); + } + } } } aView->Repaint(); @@ -453,14 +538,21 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow SOCC_Viewer* soccViewer = (SOCC_Viewer*)(viewWindow->getViewManager()->getViewModel()); SOCC_Prs* occPrs = dynamic_cast( soccViewer->CreatePrs( It.Value()->getEntry() ) ); if ( occPrs && !occPrs->IsNull() ) { - AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes ); - AIS_ListIteratorOfListOfInteractive interIter( shapes ); - for ( ; interIter.More(); interIter.Next() ) { - if ( mode == 0 ) - ic->SetDisplayMode( interIter.Value(), AIS_WireFrame, false ); - else if ( mode == 1 ) - ic->SetDisplayMode( interIter.Value(), AIS_Shaded, false ); - } + AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes ); + AIS_ListIteratorOfListOfInteractive interIter( shapes ); + for ( ; interIter.More(); interIter.Next() ) { + if ( mode == 0 ) + ic->SetDisplayMode( interIter.Value(), AIS_WireFrame, false ); + else if ( mode == 1 ) + ic->SetDisplayMode( interIter.Value(), AIS_Shaded, false ); + if (mode == 2 ) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() ); + if ( !aSh.IsNull() ) { + aSh->SetDisplayVectors(!aSh->isShowVectors()); + ic->RecomputePrsOnly(interIter.Value()); + } + } + } } } ic->UpdateCurrentViewer();