-// GEOM GEOMGUI : GUI for Geometry component
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// GEOM GEOMGUI : GUI for Geometry component
+// File : DisplayGUI.cxx
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
//
-// File : DisplayGUI.cxx
-// Author : Vadim SANDLER
-// Module : GEOM
-// $Header$
-
#include "DisplayGUI.h"
-#include "GeometryGUI.h"
-#include "GEOM_Displayer.h"
+#include <GeometryGUI.h>
+#include <GEOM_Displayer.h>
+#include <GEOM_AISShape.hxx>
+#include <GEOM_Actor.h>
#include <SUIT_Desktop.h>
-#include <SUIT_Session.h>
#include <SUIT_ViewWindow.h>
#include <SUIT_OverrideCursor.h>
#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewModel.h>
-#include <OCCViewer_ViewWindow.h>
+#include <SALOME_ListIO.hxx>
#include <SALOME_ListIteratorOfListIO.hxx>
#include <SVTK_ViewWindow.h>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
-#include <qmenubar.h>
+#include <vtkActorCollection.h>
+#include <vtkRenderer.h>
+#include <QAction>
//=======================================================================
// function : DisplayGUI::DisplayGUI()
{
InvertDisplayMode();
int newMode = GetDisplayMode();
- getGeometryGUI()->action( 211 )->setMenuText
+ getGeometryGUI()->action( 211 )->setText
( newMode == 1 ? tr( "GEOM_MEN_WIREFRAME" ) : tr("GEOM_MEN_SHADING") );
getGeometryGUI()->menuMgr()->update();
break;
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 );
ChangeDisplayMode( 1 );
break;
}
+ case 80313: // POPUP VIEWER - VECTORS
+ {
+ ChangeDisplayMode( 2 );
+ break;
+ }
default:
{
app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
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<SVTK_ViewWindow*>( 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
SVTK_Prs* vtkPrs =
stvkViewer ? dynamic_cast<SVTK_Prs*>( 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();
SOCC_Viewer* soccViewer = (SOCC_Viewer*)(viewWindow->getViewManager()->getViewModel());
SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( 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();
//=====================================================================================
extern "C"
{
- GEOM_DISPLAYGUI_EXPORT
+#ifdef WIN32
+ __declspec( dllexport )
+#endif
GEOMGUI* GetLibGUI( GeometryGUI* parent )
{
return new DisplayGUI( parent );