\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".
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
tree_group_solid.png \
tree_lcs.png \
vector.png \
+vector_mode.png \
vector2points.png \
vectordxyz.png \
whatis.png \
#include <GeometryGUI.h>
#include <GEOM_Displayer.h>
#include <GEOM_AISShape.hxx>
+#include <GEOM_Actor.h>
#include <SUIT_Desktop.h>
#include <SUIT_ViewWindow.h>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <vtkActorCollection.h>
+#include <vtkRenderer.h>
+
#include <QAction>
//=======================================================================
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));
}
//=====================================================================================
-// 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::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
//=====================================================================================
-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();
}
//=====================================================================================
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();
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());
+ }
}
}
}
// (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 );
#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>
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 );
}
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*>
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;
}
else
{
- bool isVector = (myType == GEOM_VECTOR);
+ bool isVector;
+ if (myType == GEOM_VECTOR) isVector = true;
theActors = GEOM_AssemblyBuilder::BuildActors( myShape, 0, 0, Standard_True, isVector );
}
<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>
<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>
<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>
<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>
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
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 );
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" );
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 );
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 );
sm->setSelectedObjects( selected, true ); //NPAL 19674
+ QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
+ if ( viewMenu )
+ connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
+
return true;
}
//=======================================================================
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 );
}
}
}
+
+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);
+ }
+}
private slots:
void OnGUIEvent();
void onWindowActivated( SUIT_ViewWindow* );
+ void onViewAboutToShow();
signals :
void SignalDeactivateActiveDialog();
// 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
//
#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"
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 {
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);
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);
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)
#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,
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 );
}
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...
}
anIC->SetAutomaticHilight( isAutoHilight );
anIC->HilightSelected( false );
}
+
+void GEOM_AISShape::SetDisplayVectors(bool isDisplayed)
+{
+ myDisplayVectors = isDisplayed;
+}
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_();
private:
TCollection_AsciiString myName;
+ bool myDisplayVectors;
};
// 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)
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...
}
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode = 0);
+ virtual bool isShowVectors() {return true;}
+
public:
DEFINE_STANDARD_RTTI (GEOM_AISVector)
};
// 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
#include "utilities.h"
+#include "SALOME_InteractiveObject.hxx"
+
//vtkStandardNewMacro(GEOM_Actor);
#ifndef MYDEBUG
GEOM_Actor::GEOM_Actor():
// myDisplayMode(eWireframe),
myIsSelected(false),
-
+ myVectorMode(false),
myVertexActor(GEOM_DeviceActor::New(),true),
myVertexSource(GEOM_VertexSource::New(),true),
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,
switch(aSelectionMode){
case ActorSelection :
{
+ // cout << "=============== " << myIO->getEntry() << endl;
+ int nbio = mySelector->IObjectCount();
+ // cout << " nbio = " << nbio << endl;
+
if( !mySelector->IsSelected( myIO ) ) {
+ // printf ("!!!!!!!!!!!!!!!!\n");
SetPreSelected( true );
}
}
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,
// EDisplayMode myDisplayMode;
bool myIsSelected;
+ bool myVectorMode;
PDeviceActor myVertexActor;
PVertexSource myVertexSource;
#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)
{
}
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);
}
}
+
// vector representation has an arrow on its end
if (theIsVector)
{
}
// 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.;
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();
thePolyData->InsertNextCell(VTK_LINE,2,pts);
}
}
+
+void GEOM_EdgeSource::SetVectorMode (bool theMode)
+{
+ myIsVector = theMode;
+}
+
+bool GEOM_EdgeSource::GetVectorMode ()
+{
+ return myIsVector;
+}
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,