mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-15 10:08:35 +05:00
0020082: EDF 869 GEOM : Edges Orientation indicator/reverse
This commit is contained in:
parent
a7c0d2d2ee
commit
68a6e5ca4b
@ -12,14 +12,21 @@ Wireframe</b> or <b>Shading</b>.
|
||||
|
||||
\n <b>TUI Command:</b> <em>gg.setDisplayMode(ID, Short)</em>
|
||||
|
||||
\n <b>Examples:</b>
|
||||
|
||||
\image html disp_mode1sn.png
|
||||
<center><em>Wireframe</em></center>
|
||||
|
||||
\image html /disp_mode2sn.png
|
||||
<center><em>Shading</em></center>
|
||||
|
||||
\n There is an option to show the direction of edges on the selected shape from popup menu <b> Display mode
|
||||
-> Show Edge Direction</b> or it possible to apply this functionality for all objects in the current view from
|
||||
the main menu <b> View -> Display Mode -> Show/Hide Edge Direction.</b>
|
||||
|
||||
\image html vectors_mode.png
|
||||
<center><em>Vectors Mode (Show Edge Direction)</em></center>
|
||||
|
||||
\n <b>TUI Command:</b> <em>gg.setVectorsMode(ID, Bool)</em>
|
||||
|
||||
Our <b>TUI Scripts</b> provide you with useful examples of
|
||||
\ref tui_change_disp_mode "Changing Display Parameters".
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 \
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <GeometryGUI.h>
|
||||
#include <GEOM_Displayer.h>
|
||||
#include <GEOM_AISShape.hxx>
|
||||
#include <GEOM_Actor.h>
|
||||
|
||||
#include <SUIT_Desktop.h>
|
||||
#include <SUIT_ViewWindow.h>
|
||||
@ -53,6 +54,9 @@
|
||||
|
||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||
|
||||
#include <vtkActorCollection.h>
|
||||
#include <vtkRenderer.h>
|
||||
|
||||
#include <QAction>
|
||||
|
||||
//=======================================================================
|
||||
@ -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 <viewWindow> = 0 )
|
||||
// function : DisplayGUI::SetVectorsMode()
|
||||
// purpose : Set vector mode for the viewer
|
||||
//=====================================================================================
|
||||
void DisplayGUI::InvertDisplayMode( SUIT_ViewWindow* viewWindow )
|
||||
void DisplayGUI::SetVectorMode( const bool mode, SUIT_ViewWindow* viewWindow )
|
||||
{
|
||||
SetDisplayMode( 1 - GetDisplayMode( 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();
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,13 @@ public:
|
||||
// (current viewer if <viewWindow> = 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 <viewWindow> = 0 )
|
||||
void ChangeDisplayMode( const int, SUIT_ViewWindow* = 0 );
|
||||
|
@ -41,12 +41,15 @@
|
||||
#include <SOCC_Prs.h>
|
||||
#include <SVTK_Prs.h>
|
||||
#include <SALOME_Actor.h>
|
||||
#include <GEOM_Actor.h>
|
||||
|
||||
#include <OCCViewer_ViewModel.h>
|
||||
#include <SVTK_ViewModel.h>
|
||||
|
||||
#include <GEOMImpl_Types.hxx>
|
||||
|
||||
#include <GEOM_AISShape.hxx>
|
||||
|
||||
// OCCT Includes
|
||||
#include <AIS.hxx>
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
@ -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<SVTK_Prs*>( 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<SalomeApp_Study*>
|
||||
|
@ -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;
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
|
@ -909,6 +909,10 @@
|
||||
<source>ICO_SHADING</source>
|
||||
<translation>shading.png</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ICO_VECTOR_MODE</source>
|
||||
<translation>vector_mode.png</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ICO_SHAPE_PROCESS</source>
|
||||
<translation>shapeprocess.png</translation>
|
||||
|
@ -2343,6 +2343,10 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>MEN_POP_WIREFRAME</source>
|
||||
<translation>Wireframe</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_POP_VECTORS</source>
|
||||
<translation>Show Edge Direction</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_PREFERENCES</source>
|
||||
<translation>Preferences</translation>
|
||||
@ -2488,6 +2492,14 @@ Please, select face, shell or solid and try again</translation>
|
||||
<translation>Wire</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_VECTOR_MODE_ON</source>
|
||||
<translation>Show Edge Direction</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_VECTOR_MODE_OFF</source>
|
||||
<translation>Hide Edge Direction</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_WIREFRAME</source>
|
||||
<translation>Wireframe</translation>
|
||||
</message>
|
||||
@ -2903,6 +2915,10 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>STB_SHADING</source>
|
||||
<translation>Shading</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_VECTOR_MODE</source>
|
||||
<translation>Change Edge Presentation Mode</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_SHADING_COLOR</source>
|
||||
<translation>Set shading color</translation>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -139,6 +139,7 @@ protected slots:
|
||||
private slots:
|
||||
void OnGUIEvent();
|
||||
void onWindowActivated( SUIT_ViewWindow* );
|
||||
void onViewAboutToShow();
|
||||
|
||||
signals :
|
||||
void SignalDeactivateActiveDialog();
|
||||
|
@ -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 <SOCC_Prs.h>
|
||||
|
||||
#include "SVTK_ViewModel.h"
|
||||
#include "SVTK_ViewWindow.h"
|
||||
#include "SVTK_View.h"
|
||||
#include "SVTK_Renderer.h"
|
||||
#include <SVTK_Prs.h>
|
||||
|
||||
#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<SVTK_Viewer*>(aViewWindow->getViewManager()->getViewModel());
|
||||
SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( 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<SOCC_Viewer*>(occViewer);
|
||||
if (soccViewer) {
|
||||
SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( 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 {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -52,6 +52,20 @@
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <GeomAdaptor_Curve.hxx>
|
||||
#include <GCPnts_AbscissaPoint.hxx>
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -28,18 +28,8 @@
|
||||
|
||||
// OCCT Includes
|
||||
#include <Prs3d_Presentation.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <PrsMgr_PresentationManager3d.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
|
||||
|
||||
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...
|
||||
}
|
||||
|
@ -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)
|
||||
};
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -31,13 +31,16 @@
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <Poly_PolygonOnTriangulation.hxx>
|
||||
#include <GeomAdaptor_Curve.hxx>
|
||||
#include <GCPnts_AbscissaPoint.hxx>
|
||||
|
||||
#include <vtkStripper.h>
|
||||
#include <vtkPolyData.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user