From: dmv Date: Wed, 8 Jul 2009 10:18:07 +0000 (+0000) Subject: 0020082: EDF 869 GEOM : Edges Orientation indicator/reverse X-Git-Tag: V5_1_3rc1~76 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=68a6e5ca4b8f36aabaf23089cc335da4afb4fb55;p=modules%2Fgeom.git 0020082: EDF 869 GEOM : Edges Orientation indicator/reverse --- diff --git a/doc/salome/gui/GEOM/input/display_mode.doc b/doc/salome/gui/GEOM/input/display_mode.doc index 8fe2d92f4..985c9347a 100644 --- a/doc/salome/gui/GEOM/input/display_mode.doc +++ b/doc/salome/gui/GEOM/input/display_mode.doc @@ -12,14 +12,21 @@ Wireframe or Shading. \n TUI Command: gg.setDisplayMode(ID, Short) -\n Examples: - \image html disp_mode1sn.png
Wireframe
\image html /disp_mode2sn.png
Shading
+\n There is an option to show the direction of edges on the selected shape from popup menu Display mode +-> Show Edge Direction or it possible to apply this functionality for all objects in the current view from +the main menu View -> Display Mode -> Show/Hide Edge Direction. + +\image html vectors_mode.png +
Vectors Mode (Show Edge Direction)
+ +\n TUI Command: gg.setVectorsMode(ID, Bool) + Our TUI Scripts provide you with useful examples of \ref tui_change_disp_mode "Changing Display Parameters". diff --git a/doc/salome/gui/GEOM/input/tui_viewing_geom_objs.doc b/doc/salome/gui/GEOM/input/tui_viewing_geom_objs.doc index 146bd33fd..743205b57 100644 --- a/doc/salome/gui/GEOM/input/tui_viewing_geom_objs.doc +++ b/doc/salome/gui/GEOM/input/tui_viewing_geom_objs.doc @@ -9,14 +9,18 @@ import salome import geompy box = geompy.MakeBox(0,0,0, 50,50,50) +box2 = geompy.MakeBox(-50,-50,-50, 0,0,0) sphere = geompy.MakeSphere(50,50,50, 30) fuse = geompy.MakeBoolean(box,sphere,3) fuse_id = geompy.addToStudy(fuse,"Fuse") +box_id = geompy.addToStudy(box2, "Box") gg = salome.ImportComponentGUI("GEOM") gg.createAndDisplayGO(fuse_id) -gg.setDisplayMode(fuse_id,1) +gg.setDisplayMode(fuse_id,1) +gg.createAndDisplayGO(box_id) +gg.setVectorsMode(box_id, 1) \endcode \anchor tui_change_color diff --git a/resources/Makefile.am b/resources/Makefile.am index 4dd5020f5..e8bc26310 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -170,6 +170,7 @@ tree_group_face.png \ tree_group_solid.png \ tree_lcs.png \ vector.png \ +vector_mode.png \ vector2points.png \ vectordxyz.png \ whatis.png \ diff --git a/src/DisplayGUI/DisplayGUI.cxx b/src/DisplayGUI/DisplayGUI.cxx index 6b62fe2fe..3cfa07c76 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)); @@ -393,13 +411,62 @@ int DisplayGUI::GetDisplayMode( SUIT_ViewWindow* viewWindow ) } //===================================================================================== -// function : DisplayGUI::InvertDisplayMode() -// purpose : Invert display mode ( shadin <-> wireframe ) for the viewer -// (current viewer if = 0 ) +// 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 //===================================================================================== -void DisplayGUI::InvertDisplayMode( SUIT_ViewWindow* viewWindow ) +int DisplayGUI::GetVectorMode( SUIT_ViewWindow* viewWindow ) { - SetDisplayMode( 1 - GetDisplayMode( viewWindow ) ); + if ( !viewWindow ) + viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow(); + return viewWindow->getCustomData( "VectorsMode" ).toBool(); } //===================================================================================== @@ -438,6 +505,14 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow 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(); @@ -460,6 +535,11 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow 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() ); + aSh->SetDisplayVectors(!aSh->isShowVectors()); + ic->RecomputePrsOnly(interIter.Value()); + } } } } diff --git a/src/DisplayGUI/DisplayGUI.h b/src/DisplayGUI/DisplayGUI.h index d9e089e2a..2ad5a05ae 100644 --- a/src/DisplayGUI/DisplayGUI.h +++ b/src/DisplayGUI/DisplayGUI.h @@ -64,6 +64,13 @@ public: // (current viewer if = 0 ) void InvertDisplayMode( SUIT_ViewWindow* = 0 ); + // VECTOR MODE methods + // Set vectror mode for the viewer + void SetVectorMode( const bool, SUIT_ViewWindow* = 0 ); + // Get vector mode of the viewer + int GetVectorMode( SUIT_ViewWindow* = 0 ); + // Invert vector mode ( shadin <-> wireframe ) for the viewer + // Set display mode for selected objects in the viewer given // (current viewer if = 0 ) void ChangeDisplayMode( const int, SUIT_ViewWindow* = 0 ); diff --git a/src/GEOMGUI/GEOMGUI_Selection.cxx b/src/GEOMGUI/GEOMGUI_Selection.cxx index d89088f61..8969e8b4f 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.cxx +++ b/src/GEOMGUI/GEOMGUI_Selection.cxx @@ -41,12 +41,15 @@ #include #include #include +#include #include #include #include +#include + // OCCT Includes #include #include @@ -84,6 +87,8 @@ QVariant GEOMGUI_Selection::parameter( const int ind, const QString& p ) const return QVariant( displayMode( ind ) ); else if ( p == "isAutoColor" ) return QVariant( isAutoColor( ind ) ); + else if ( p == "isVectorsMode" ) + return QVariant( isVectorsMode( ind ) ); else return LightApp_Selection::parameter( ind, p ); } @@ -177,6 +182,42 @@ QString GEOMGUI_Selection::displayMode( const int index ) const return ""; } +bool GEOMGUI_Selection::isVectorsMode( const int index ) const +{ + bool ret = false; + SALOME_View* view = GEOM_Displayer::GetActiveView(); + QString viewType = activeViewType(); + if ( view && ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) { + SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() ); + if ( prs ) { + if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC + SOCC_Prs* occPrs = (SOCC_Prs*) prs; + AIS_ListOfInteractive lst; + occPrs->GetObjects( lst ); + if ( lst.Extent() ) { + Handle(AIS_InteractiveObject) io = lst.First(); + if ( !io.IsNull() ) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io); + ret = aSh->isShowVectors(); + } + } + } else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK + SVTK_Prs* vtkPrs = dynamic_cast( prs ); + vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0; + if ( lst ) { + lst->InitTraversal(); + vtkActor* actor = lst->GetNextActor(); + if ( actor ) { + GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(actor); + ret = aGeomActor->GetVectorMode(); + } + } + } + } + } + return ret; +} + bool GEOMGUI_Selection::isComponent( const int index ) const { SalomeApp_Study* appStudy = dynamic_cast diff --git a/src/GEOMGUI/GEOMGUI_Selection.h b/src/GEOMGUI/GEOMGUI_Selection.h index 35b90f225..d03570ec0 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.h +++ b/src/GEOMGUI/GEOMGUI_Selection.h @@ -49,6 +49,7 @@ private: QString typeName( const int ) const; QString displayMode( const int ) const; QString selectionMode() const; + bool isVectorsMode( const int ) const; bool isComponent( const int ) const; GEOM::GEOM_Object_ptr getObject( const int ) const; diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index b183b3f53..f8aaa621b 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -813,7 +813,8 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) } else { - bool isVector = (myType == GEOM_VECTOR); + bool isVector; + if (myType == GEOM_VECTOR) isVector = true; theActors = GEOM_AssemblyBuilder::BuildActors( myShape, 0, 0, Standard_True, isVector ); } diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index a4c96d025..91d67566e 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -909,6 +909,10 @@ ICO_SHADING shading.png + + ICO_VECTOR_MODE + vector_mode.png + ICO_SHAPE_PROCESS shapeprocess.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index c6ffb7c1f..c30b27932 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -2343,6 +2343,10 @@ Please, select face, shell or solid and try again MEN_POP_WIREFRAME Wireframe + + MEN_POP_VECTORS + Show Edge Direction + MEN_PREFERENCES Preferences @@ -2488,6 +2492,14 @@ Please, select face, shell or solid and try again Wire + MEN_VECTOR_MODE_ON + Show Edge Direction + + + MEN_VECTOR_MODE_OFF + Hide Edge Direction + + MEN_WIREFRAME Wireframe @@ -2903,6 +2915,10 @@ Please, select face, shell or solid and try again STB_SHADING Shading + + STB_VECTOR_MODE + Change Edge Presentation Mode + STB_SHADING_COLOR Set shading color diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index be3e9ca46..7706ad9d6 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -402,8 +402,10 @@ void GeometryGUI::OnGUIEvent( int id ) id == 214 || // MENU VIEW - ERASE ALL id == 215 || // MENU VIEW - ERASE id == 216 || // MENU VIEW - DISPLAY + id == 218 || // MENU VIEW - VECTOR MODE id == 80311 || // POPUP VIEWER - WIREFRAME - id == 80312 ) { // POPUP VIEWER - SHADING + id == 80312 || // POPUP VIEWER - SHADING + id == 80313 ) { // POPUP VIEWER - VECTORS #ifndef WNT library = getLibrary( "libDisplayGUI.so" ); #else @@ -880,6 +882,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( 212, "DISPLAY_ALL" ); createGeomAction( 214, "ERASE_ALL" ); createGeomAction( 216, "DISPLAY" ); + createGeomAction( 218, "VECTOR_MODE"); createGeomAction( 2171, "VERTEX_SEL_ONLY" ,"", 0, true ); createGeomAction( 2172, "EDGE_SEL_ONLY", "", 0, true ); createGeomAction( 2173, "WIRE_SEL_ONLY", "", 0, true ); @@ -894,6 +897,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( 901, "POP_RENAME", "", Qt::Key_F2 ); createGeomAction( 80311, "POP_WIREFRAME", "", 0, true ); createGeomAction( 80312, "POP_SHADING", "", 0, true ); + createGeomAction( 80313, "POP_VECTORS", "", 0, true ); createGeomAction( 8032, "POP_COLOR" ); createGeomAction( 8033, "POP_TRANSPARENCY" ); createGeomAction( 8034, "POP_ISOS" ); @@ -1059,6 +1063,8 @@ void GeometryGUI::initialize( CAM_Application* app ) int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 ); createMenu( 211, dispmodeId, -1 ); + createMenu( separator(), dispmodeId, -1 ); + createMenu( 218, dispmodeId, -1 ); createMenu( separator(), viewId, -1 ); createMenu( 212, viewId, -1 ); @@ -1149,6 +1155,10 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->insert( action( 80312 ), dispmodeId, -1 ); // shading mgr->setRule( action( 80312 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule ); mgr->setRule( action( 80312 ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule ); + mgr->insert( separator(), dispmodeId, -1 ); + mgr->insert( action( 80313 ), dispmodeId, -1 ); // vectors + mgr->setRule( action( 80313 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule ); + mgr->setRule( action( 80313 ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule ); mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( action( 8032 ), -1, -1 ); // color mgr->setRule( action( 8032 ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); @@ -1281,6 +1291,10 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) sm->setSelectedObjects( selected, true ); //NPAL 19674 + QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId ); + if ( viewMenu ) + connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) ); + return true; } @@ -1291,6 +1305,10 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) //======================================================================= bool GeometryGUI::deactivateModule( SUIT_Study* study ) { + QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId ); + if ( viewMenu ) + disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) ); + setMenuShown( false ); setToolShown( false ); @@ -2045,3 +2063,17 @@ void GeometryGUI::restoreVisualParameters (int savePoint) } } } + +void GeometryGUI::onViewAboutToShow() +{ + SUIT_ViewWindow* window = application()->desktop()->activeWindow(); + QAction* a = action( 218 ); + if ( window ) { + a->setEnabled(true); + bool vmode = window->getCustomData("VectorsMode").toBool(); + a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") ); + } else { + a->setText ( tr("MEN_VECTOR_MODE_ON") ); + a->setEnabled(false); + } +} diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index 36d06fd55..8282dccc3 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -139,6 +139,7 @@ protected slots: private slots: void OnGUIEvent(); void onWindowActivated( SUIT_ViewWindow* ); + void onViewAboutToShow(); signals : void SignalDeactivateActiveDialog(); diff --git a/src/GEOMGUI/GeometryGUI_Swig.cxx b/src/GEOMGUI/GeometryGUI_Swig.cxx index e1e8f1390..844b669e8 100644 --- a/src/GEOMGUI/GeometryGUI_Swig.cxx +++ b/src/GEOMGUI/GeometryGUI_Swig.cxx @@ -1,5 +1,6 @@ // Copyright (C) 2007-2008 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 // @@ -37,11 +38,13 @@ #include "OCCViewer_ViewWindow.h" #include "OCCViewer_ViewManager.h" #include "SOCC_ViewModel.h" +#include #include "SVTK_ViewModel.h" #include "SVTK_ViewWindow.h" #include "SVTK_View.h" #include "SVTK_Renderer.h" +#include #include "GEOM_Actor.h" #include "GEOM_Client.hxx" @@ -393,6 +396,58 @@ void GEOM_Swig::setDisplayMode(const char* theEntry, int theMode, bool isUpdated ProcessVoidEvent(new TEvent (theEntry, theMode, isUpdated)); } +void GEOM_Swig::setVectorsMode(const char* theEntry, bool isOn, bool isUpdated) +{ + class TEvent: public SALOME_Event { + std::string myEntry; + bool myOn; + bool myUpdateViewer; + public: + TEvent(const char* theEntryArg, bool theOn, bool theUpdated): + myEntry(theEntryArg), myOn(theOn), myUpdateViewer(theUpdated) + {} + virtual void Execute() { + SUIT_Application* anApp = SUIT_Session::session()->activeApplication(); + if (!anApp) return; + + Handle(SALOME_InteractiveObject) anIO = + new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", ""); + + if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) { + SVTK_View* aView = aViewWindow->getView(); + SVTK_Viewer* stvkViewer = dynamic_cast(aViewWindow->getViewManager()->getViewModel()); + SVTK_Prs* vtkPrs = dynamic_cast( stvkViewer->CreatePrs( myEntry.c_str() ) ); + vtkActorCollection* anActors = vtkPrs->GetObjects(); + anActors->InitTraversal(); + while (vtkActor* anAct = anActors->GetNextActor()) { + GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(anAct); + aGeomActor->SetVectorMode(!aGeomActor->GetVectorMode()); + } + if (myUpdateViewer) + aView->Repaint(); + } + else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) { + Handle(AIS_InteractiveContext) ic = occViewer->getAISContext(); + SOCC_Viewer* soccViewer = dynamic_cast(occViewer); + if (soccViewer) { + SOCC_Prs* occPrs = dynamic_cast( soccViewer->CreatePrs( myEntry.c_str() ) ); + if ( occPrs && !occPrs->IsNull() ) { + AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes ); + AIS_ListIteratorOfListOfInteractive interIter( shapes ); + for ( ; interIter.More(); interIter.Next() ) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() ); + aSh->SetDisplayVectors(myOn); + ic->RecomputePrsOnly(interIter.Value()); + } + } + } + } + } + }; + + ProcessVoidEvent(new TEvent (theEntry, isOn, isUpdated)); +} + void GEOM_Swig::setColor(const char* theEntry, int red, int green, int blue, bool isUpdated) { class TEvent: public SALOME_Event { diff --git a/src/GEOMGUI/GeometryGUI_Swig.hxx b/src/GEOMGUI/GeometryGUI_Swig.hxx index a0f079ac3..f6e4dfee0 100644 --- a/src/GEOMGUI/GeometryGUI_Swig.hxx +++ b/src/GEOMGUI/GeometryGUI_Swig.hxx @@ -45,6 +45,7 @@ public: void createAndDisplayFitAllGO(const char* Entry); void UpdateViewer(); void setDisplayMode(const char* Entry, int mode, bool isUpdated = true); + void setVectorsMode(const char* Entry, bool isSet, bool isUpdated = true); void setColor(const char* Entry, int red, int green, int blue, bool isUpdated = true); void setTransparency(const char* Entry, float transp, bool isUpdated = true); void setDeflection(const char* Entry, float deflect); diff --git a/src/GEOMGUI/GeometryGUI_Swig.i b/src/GEOMGUI/GeometryGUI_Swig.i index 4fa8d7ea2..e677b45fb 100644 --- a/src/GEOMGUI/GeometryGUI_Swig.i +++ b/src/GEOMGUI/GeometryGUI_Swig.i @@ -61,6 +61,7 @@ class GEOM_Swig const char* getShapeTypeString(const char *Entry); void setDisplayMode(const char* Entry, int mode, bool isUpdated =true); + void setVectorsMode(const char* Entry, bool isSet, bool isUpdated =true); void setColor(const char* Entry, int red, int green, int blue, bool isUpdated =true); void setTransparency(const char* Entry, float transp, bool isUpdated =true); void setDeflection(const char* Entry, float deflect); diff --git a/src/GEOM_SWIG/GEOM_example3.py b/src/GEOM_SWIG/GEOM_example3.py index 3c5bd0498..8bd43a283 100644 --- a/src/GEOM_SWIG/GEOM_example3.py +++ b/src/GEOM_SWIG/GEOM_example3.py @@ -110,7 +110,7 @@ if not isinstance(gg, type(salome_ComponentGUI)): gg.setDisplayMode(id_torus1,1) gg.setDisplayMode(id_torus2,1) - gg.setDisplayMode(id_acyl,1) + gg.setVectorsMode(id_acyl,1,1) #gg.setDisplayMode(id_cage,1) gg.setColor(id_torus1,0,0,255) diff --git a/src/OBJECT/GEOM_AISShape.cxx b/src/OBJECT/GEOM_AISShape.cxx index a40b492e4..f7ce2534f 100644 --- a/src/OBJECT/GEOM_AISShape.cxx +++ b/src/OBJECT/GEOM_AISShape.cxx @@ -52,6 +52,20 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + using namespace std; static void getEntityOwners( const Handle(AIS_InteractiveObject)& theObj, @@ -110,7 +124,7 @@ static void indicesToOwners( const TColStd_IndexedMapOfInteger& aIndexMap, GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape, const Standard_CString aName) - : SALOME_AISShape(shape), myName(aName) + : SALOME_AISShape(shape), myName(aName), myDisplayVectors(false) { myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD ); } @@ -189,6 +203,32 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent break; } } + + if (isShowVectors()) + { + TopExp_Explorer Exp ( myshape, TopAbs_EDGE ); + for ( ; Exp.More(); Exp.Next() ) { + TopoDS_Vertex aV1, aV2; + TopoDS_Edge anEdgeE = TopoDS::Edge(Exp.Current()); + TopExp::Vertices(anEdgeE, aV1, aV2); + gp_Pnt aP1 = BRep_Tool::Pnt(aV1); + gp_Pnt aP2 = BRep_Tool::Pnt(aV2); + + double fp,lp; + gp_Vec aDirVec; + Handle(Geom_Curve) C = BRep_Tool::Curve(anEdgeE,fp,lp); + C->D1(lp, aP2, aDirVec); + + GeomAdaptor_Curve aAdC; + aAdC.Load(C, fp, lp); + Standard_Real aDist = GCPnts_AbscissaPoint::Length(aAdC, fp, lp); + + if (aDist > gp::Resolution()) { + gp_Dir aDir (aDirVec); + Prs3d_Arrow::Draw(aPrs, aP2, aDir, PI/180.*5., aDist/10.); + } + } + } // aPrs->ReCompute(); // for hidden line recomputation if necessary... } @@ -245,3 +285,8 @@ void GEOM_AISShape::highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndex anIC->SetAutomaticHilight( isAutoHilight ); anIC->HilightSelected( false ); } + +void GEOM_AISShape::SetDisplayVectors(bool isDisplayed) +{ + myDisplayVectors = isDisplayed; +} diff --git a/src/OBJECT/GEOM_AISShape.hxx b/src/OBJECT/GEOM_AISShape.hxx index 643d51019..188e29b54 100644 --- a/src/OBJECT/GEOM_AISShape.hxx +++ b/src/OBJECT/GEOM_AISShape.hxx @@ -94,11 +94,14 @@ public: void SetTransparency(const Standard_Real aValue); void SetShadingColor(const Quantity_Color &aCol); + void SetDisplayVectors(bool isShow); virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) ; + virtual bool isShowVectors () { return myDisplayVectors; } + // Type management // friend Handle_Standard_Type& GEOM_AISShape_Type_(); @@ -110,6 +113,7 @@ protected: private: TCollection_AsciiString myName; + bool myDisplayVectors; }; diff --git a/src/OBJECT/GEOM_AISVector.cxx b/src/OBJECT/GEOM_AISVector.cxx index 44262f149..528e2a5a8 100644 --- a/src/OBJECT/GEOM_AISVector.cxx +++ b/src/OBJECT/GEOM_AISVector.cxx @@ -28,18 +28,8 @@ // OCCT Includes #include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include + IMPLEMENT_STANDARD_HANDLE(GEOM_AISVector, GEOM_AISShape) IMPLEMENT_STANDARD_RTTIEXT(GEOM_AISVector, GEOM_AISShape) @@ -62,28 +52,4 @@ void GEOM_AISVector::Compute (const Handle(PrsMgr_PresentationManager3d)& thePre const Standard_Integer theMode) { GEOM_AISShape::Compute(thePresentationManager, thePrs, theMode); - - if (myshape.ShapeType() == TopAbs_EDGE) - { - TopoDS_Vertex aV1, aV2; - TopoDS_Edge anEdgeE = TopoDS::Edge(myshape); - TopExp::Vertices(anEdgeE, aV1, aV2); - gp_Pnt aP1 = BRep_Tool::Pnt(aV1); - gp_Pnt aP2 = BRep_Tool::Pnt(aV2); - - gp_Vec aVec (aP1, aP2); - Standard_Real aDist = aVec.Magnitude(); - if (aDist > gp::Resolution()) - { - gp_Dir aDir (aVec); - - Handle(Graphic3d_Group) aG = Prs3d_Root::CurrentGroup(thePrs); - - //thePrs->Color(myShadingColor.Name()); - //aG->BeginPrimitives(); - Prs3d_Arrow::Draw(thePrs, aP2, aDir, PI/180.*5., aDist/10.); - //aG->EndPrimitives(); - } - } - //thePrs->ReCompute(); // for hidden line recomputation if necessary... } diff --git a/src/OBJECT/GEOM_AISVector.hxx b/src/OBJECT/GEOM_AISVector.hxx index 2ffbf3a4f..1a61a9e8b 100644 --- a/src/OBJECT/GEOM_AISVector.hxx +++ b/src/OBJECT/GEOM_AISVector.hxx @@ -53,6 +53,8 @@ protected: const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0); + virtual bool isShowVectors() {return true;} + public: DEFINE_STANDARD_RTTI (GEOM_AISVector) }; diff --git a/src/OBJECT/GEOM_Actor.cxx b/src/OBJECT/GEOM_Actor.cxx index e4fd57eb8..cb0ad3529 100644 --- a/src/OBJECT/GEOM_Actor.cxx +++ b/src/OBJECT/GEOM_Actor.cxx @@ -17,8 +17,7 @@ // 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 -// +// See http://ww // GEOM OBJECT : interactive object for Geometry entities visualization // File : GEOM_Actor.cxx // Author : Christophe ATTANASIO @@ -68,6 +67,8 @@ #include "utilities.h" +#include "SALOME_InteractiveObject.hxx" + //vtkStandardNewMacro(GEOM_Actor); #ifndef MYDEBUG @@ -77,7 +78,7 @@ GEOM_Actor::GEOM_Actor(): // myDisplayMode(eWireframe), myIsSelected(false), - + myVectorMode(false), myVertexActor(GEOM_DeviceActor::New(),true), myVertexSource(GEOM_VertexSource::New(),true), @@ -333,6 +334,24 @@ GEOM_Actor myWireframeFaceSource->GetNbIso(theNbU, theNbV); } +void +GEOM_Actor +::SetVectorMode(bool theMode) +{ + myVectorMode = theMode; + myIsolatedEdgeSource->SetVectorMode(theMode); + myOneFaceEdgeSource->SetVectorMode(theMode); + mySharedEdgeSource->SetVectorMode(theMode); + SetModified(); +} + +bool +GEOM_Actor +::GetVectorMode() +{ + return myVectorMode; +} + static void MeshShape(const TopoDS_Shape& theShape, @@ -749,7 +768,12 @@ GEOM_Actor switch(aSelectionMode){ case ActorSelection : { + // cout << "=============== " << myIO->getEntry() << endl; + int nbio = mySelector->IObjectCount(); + // cout << " nbio = " << nbio << endl; + if( !mySelector->IsSelected( myIO ) ) { + // printf ("!!!!!!!!!!!!!!!!\n"); SetPreSelected( true ); } } diff --git a/src/OBJECT/GEOM_Actor.h b/src/OBJECT/GEOM_Actor.h index 600bd6781..e2e46379c 100644 --- a/src/OBJECT/GEOM_Actor.h +++ b/src/OBJECT/GEOM_Actor.h @@ -162,6 +162,15 @@ public: virtual void GetNbIsos(int &theNbU,int &theNbV); + + //! Vector mode management + virtual + void + SetVectorMode(const bool theMode); + + virtual + bool + GetVectorMode(); protected: void SetShape(const TopoDS_Shape& theShape, @@ -186,6 +195,7 @@ private: // EDisplayMode myDisplayMode; bool myIsSelected; + bool myVectorMode; PDeviceActor myVertexActor; PVertexSource myVertexSource; diff --git a/src/OBJECT/GEOM_EdgeSource.cxx b/src/OBJECT/GEOM_EdgeSource.cxx index 12b467de9..754f38c09 100755 --- a/src/OBJECT/GEOM_EdgeSource.cxx +++ b/src/OBJECT/GEOM_EdgeSource.cxx @@ -31,13 +31,16 @@ #include #include #include +#include +#include #include #include - + vtkStandardNewMacro(GEOM_EdgeSource); -GEOM_EdgeSource::GEOM_EdgeSource() +GEOM_EdgeSource::GEOM_EdgeSource() : + myIsVector(false) { } @@ -129,8 +132,8 @@ void GEOM_EdgeSource::OCC2VTK (const TopoDS_Edge& theEdge, const TColStd_Array1OfInteger& aNodeIds = aEdgePoly->Nodes(); const TColgp_Array1OfPnt& anId2Pnts = T->Nodes(); - aP1 = anId2Pnts(1); - aP2 = anId2Pnts(aNbNodes); + aP1 = anId2Pnts(aNodeIds(1)); + aP2 = anId2Pnts(aNodeIds(aNbNodes)); for(int j = 1; j < aNbNodes; j++) { Standard_Integer id1 = aNodeIds(j); @@ -156,6 +159,7 @@ void GEOM_EdgeSource::OCC2VTK (const TopoDS_Edge& theEdge, } } + // vector representation has an arrow on its end if (theIsVector) { @@ -166,9 +170,17 @@ void GEOM_EdgeSource::OCC2VTK (const TopoDS_Edge& theEdge, } // draw an arrow - gp_Vec aDirVec (aP1, aP2); - Standard_Real aDist = aDirVec.Magnitude(); + + double fp,lp; + gp_Vec aDirVec; + Handle(Geom_Curve) C = BRep_Tool::Curve(theEdge,fp,lp); + C->D1(lp, aP2, aDirVec); + + GeomAdaptor_Curve aAdC; + aAdC.Load(C, fp, lp); + Standard_Real aDist = GCPnts_AbscissaPoint::Length(aAdC, fp, lp); if (aDist < gp::Resolution()) return; + gp_Dir aDirection (aDirVec); Standard_Real anAngle = PI/180.*5.; @@ -177,14 +189,14 @@ void GEOM_EdgeSource::OCC2VTK (const TopoDS_Edge& theEdge, Standard_Real dx,dy,dz; aDirection.Coord(dx,dy,dz); - // Pointe de la fleche + // Arrow Point Standard_Real xo,yo,zo; aP2.Coord(xo,yo,zo); - // Centre du cercle base de la fleche + // Center of circle that arrow based gp_XYZ aPc = aP2.XYZ() - aDirection.XYZ() * aLength; - // Construction d'un repere i,j pour le cercle + // Construction of the base vectors for the arrow circle gp_Dir aDirN; if (Abs(dx) <= Abs(dy) && Abs(dx) <= Abs(dz)) aDirN = gp::DX(); else if (Abs(dy) <= Abs(dz) && Abs(dy) <= Abs(dx)) aDirN = gp::DY(); @@ -240,3 +252,13 @@ void GEOM_EdgeSource::OCC2VTK (const TopoDS_Edge& theEdge, thePolyData->InsertNextCell(VTK_LINE,2,pts); } } + +void GEOM_EdgeSource::SetVectorMode (bool theMode) +{ + myIsVector = theMode; +} + +bool GEOM_EdgeSource::GetVectorMode () +{ + return myIsVector; +} diff --git a/src/OBJECT/GEOM_EdgeSource.h b/src/OBJECT/GEOM_EdgeSource.h index 8bcfa05b2..7badc29bb 100755 --- a/src/OBJECT/GEOM_EdgeSource.h +++ b/src/OBJECT/GEOM_EdgeSource.h @@ -40,7 +40,11 @@ public: void AddEdge (const TopoDS_Edge& theEdge, bool theIsVector = false); - void Clear(){ myEdgeSet.Clear();} + void Clear(){ myEdgeSet.Clear();} + + void SetVectorMode(bool); + + bool GetVectorMode(); static void OCC2VTK(const TopoDS_Edge& theEdge,