-// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include "DisplayGUI.h"
#include <GeometryGUI.h>
#include "GeometryGUI_Operations.h"
+#include <GEOM_Constants.h>
#include <GEOM_Displayer.h>
#include <GEOM_AISShape.hxx>
#include <GEOM_Actor.h>
Sel->selectedObjects( selected );
switch ( theCommandID ) {
- case GEOMOp::OpDisplayMode: // MENU VIEW - DISPLAY MODE - WIREFRAME/SHADING
- InvertDisplayMode();
- getGeometryGUI()->action( GEOMOp::OpDisplayMode )->setText
- ( GetDisplayMode() == 1 ? tr( "GEOM_MEN_WIREFRAME" ) : tr("GEOM_MEN_SHADING") );
- getGeometryGUI()->menuMgr()->update();
+ case GEOMOp::OpDMWireframe: // MENU VIEW - DISPLAY MODE - WIREFRAME
+ SetDisplayMode( 0 );
+ break;
+ case GEOMOp::OpDMShading: // MENU VIEW - DISPLAY MODE - SHADING
+ SetDisplayMode( 1 );
+ break;
+ case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - DISPLAY MODE - SHADING WITH EDGES
+ SetDisplayMode( 2 );
break;
case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
getGeometryGUI()->EmitSignalDeactivateDialog();
case GEOMOp::OpShading: // POPUP MENU - DISPLAY MODE - SHADING
ChangeDisplayMode( 1 );
break;
+ case GEOMOp::OpShadingWithEdges: // POPUP MENU - DISPLAY MODE - SHADING WITH EDGES
+ ChangeDisplayMode( 2 );
+ break;
case GEOMOp::OpTexture: // POPUP MENU - DISPLAY MODE - TEXTURE
ChangeDisplayMode( 3 );
break;
- case GEOMOp::OpVectors: // POPUP MENU - DISPLAY MODE - SHOW EDGE DIRECTION
- ChangeDisplayMode( 2 );
+ case GEOMOp::OpVectors: // POPUP MENU - DISPLAY MODE - SHOW EDGE DIRECTION
+ ChangeDisplayMode( 4 );
break;
default:
app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer();
Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
- AIS_DisplayMode newmode = (mode == 1 ? AIS_Shaded : AIS_WireFrame);
+
+ AIS_DisplayMode newmode;
+ switch (mode) {
+ case 0:
+ newmode = AIS_WireFrame;
+ break;
+ case 1:
+ newmode = AIS_Shaded;
+ break;
+ case 2:
+ newmode = AIS_DisplayMode( GEOM_AISShape::ShadingWithEdges );
+ break;
+ case 3:
+ newmode = AIS_DisplayMode( GEOM_AISShape::TexturedShape );
+ break;
+ default:
+ break;
+ }
+
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() );
- ic->SetDisplayMode( aSh, Standard_Integer( newmode ),true );
+ Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( ite.Value() );
+ ic->SetDisplayMode( aSh, Standard_Integer( newmode ),true );
}
ite.Next();
}
-
+
ic->SetDisplayMode( newmode, Standard_False );
- GeometryGUI::Modified();
- }
-}
-//=====================================================================================
-// function : DisplayGUI::GetDisplayMode()
-// purpose : Get display mode of the viewer (current viewer if <viewWindow> - 0 )
-//=====================================================================================
-int DisplayGUI::GetDisplayMode( SUIT_ViewWindow* viewWindow )
-{
- int dispMode = 0;
- if ( !viewWindow )
- viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow();
- if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
- SVTK_View* aView = ((SVTK_ViewWindow*)viewWindow)->getView();
- dispMode = aView->GetDisplayMode();
- }
- else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
- OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer();
- Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
- AIS_DisplayMode mode = (AIS_DisplayMode)ic->DisplayMode();
- dispMode = (mode == AIS_WireFrame ? 0 : 1 );
+ GeometryGUI::Modified();
}
- return dispMode;
}
//=====================================================================================
return viewWindow->property( "VectorsMode" ).toBool();
}
-//=====================================================================================
-// function : DisplayGUI::InvertDisplayMode()
-// purpose : Invert display mode ( shadin <-> wireframe ) for the viewer
-// (current viewer if <viewWindow> = 0 )
-//=====================================================================================
-void DisplayGUI::InvertDisplayMode( SUIT_ViewWindow* viewWindow )
-{
- SetDisplayMode( 1 - GetDisplayMode( viewWindow ) );
-}
-
//=====================================================================================
// function : DisplayGUI::ChangeDisplayMode()
// purpose : Set display mode for selected objects in the viewer given
SVTK_Prs* vtkPrs =
stvkViewer ? dynamic_cast<SVTK_Prs*>( stvkViewer->CreatePrs( It.Value()->getEntry() ) ) : 0;
if ( vtkPrs && !vtkPrs->IsNull() ) {
- if ( mode == 0 )
+ if (mode == 0 )
aView->ChangeRepresentationToWireframe( vtkPrs->GetObjects() );
- else if ( mode == 1 )
+ else if ( mode == 1 )
aView->ChangeRepresentationToSurface( vtkPrs->GetObjects() );
- else if ( mode == 2 ) {
+ else if ( mode == 2 )
+ aView->ChangeRepresentationToSurfaceWithEdges( vtkPrs->GetObjects() );
+ else if ( mode == 4 ) {
vtkActorCollection* anActors = vtkPrs->GetObjects();
anActors->InitTraversal();
while (vtkActor* anAct = anActors->GetNextActor()) {
aGeomActor->SetVectorMode(vectorMode);
}
}
- if(mode == 0 || mode == 1) {
- aStudy->setObjectProperty(mgrId,It.Value()->getEntry(),DISPLAY_MODE_PROP, mode);
- }
- else if (mode == 3) {
- aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP , vectorMode);
- }
+ if(mode == 0 || mode == 1 || mode == 2) {
+ aStudy->setObjectProperty(mgrId,It.Value()->getEntry(),DISPLAY_MODE_PROP, mode);
+ }
+ else if (mode == 4) {
+ aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode);
+ }
}
}
aView->Repaint();
AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes );
AIS_ListIteratorOfListOfInteractive interIter( shapes );
for ( ; interIter.More(); interIter.Next() ) {
- if ( mode == 0 )
+ if ( mode == 0 )
ic->SetDisplayMode( interIter.Value(), AIS_WireFrame, false );
- else if ( mode == 1 )
+ else if ( mode == 1 )
ic->SetDisplayMode( interIter.Value(), AIS_Shaded, false );
- else if ( mode == 3 )
+ else if ( mode == 2 )
+ ic->SetDisplayMode( interIter.Value(), GEOM_AISShape::ShadingWithEdges, false );
+ else if ( mode == 3 )
ic->SetDisplayMode( interIter.Value(), AIS_ExactHLR, false );
- else if (mode == 2 ) {
- Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
+ else if (mode == 4 ) {
+ Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
if ( !aSh.IsNull() ) {
vectorMode = !aSh->isShowVectors();
aSh->SetDisplayVectors(vectorMode);
}
}
}
- if(mode == 0 || mode == 1) {
- aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),DISPLAY_MODE_PROP, mode);
- } else if (mode == 2) {
- aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode);
- }
+ if(mode == 0 || mode == 1 || mode == 2 || mode == 3) {
+ aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),DISPLAY_MODE_PROP, mode);
+ }
+ else if (mode == 4) {
+ aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode);
+ }
}
}
ic->UpdateCurrentViewer();