2. To make pickers member of SVTK_InteractorStyle, not to use vtkRenderWindowInteractor's ones
#include "VTKViewer_CellRectPicker.h"
#include "SVTK_Actor.h"
-#include "SVTK_InteractorStyle.h"
-
-// SALOME Includes
-//#include "utilities.h"
// VTK Includes
#include <vtkCell.h>
#include <vtkDataSetMapper.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
-#include "vtkOutlineSource.h"
+#include <vtkOutlineSource.h>
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
-//using namespace std;
+#include "utilities.h"
+
+using namespace std;
#if defined __GNUC__
#if __GNUC__ == 2
int SALOME_POINT_SIZE = 3;
+//----------------------------------------------------------------------------
vtkStandardNewMacro(SALOME_Actor);
-SALOME_Actor::SALOME_Actor(){
+//----------------------------------------------------------------------------
+SALOME_Actor
+::SALOME_Actor()
+{
myIsHighlighted = myIsPreselected = false;
myRepresentation = 1;
}
-SALOME_Actor::~SALOME_Actor(){
+//----------------------------------------------------------------------------
+SALOME_Actor
+::~SALOME_Actor()
+{
SetPreviewProperty(NULL);
myGeomFilter->UnRegisterAllOutputs();
}
-void SALOME_Actor::AddToRender(vtkRenderer* theRenderer){
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::AddToRender(vtkRenderer* theRenderer)
+{
theRenderer->AddActor(this);
// from VISU
theRenderer->AddActor( myOutlineActor );
}
-void SALOME_Actor::RemoveFromRender(vtkRenderer* theRenderer){
+void
+SALOME_Actor
+::RemoveFromRender(vtkRenderer* theRenderer)
+{
theRenderer->RemoveActor(this);
// from VISU
}
-void SALOME_Actor::SetTransform(VTKViewer_Transform* theTransform){
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::SetTransform(VTKViewer_Transform* theTransform)
+{
myTransformFilter->SetTransform(theTransform);
}
-void SALOME_Actor::SetMapper(vtkMapper* theMapper){
+void
+SALOME_Actor
+::SetMapper(vtkMapper* theMapper)
+{
InitPipeLine(theMapper);
}
-void SALOME_Actor::InitPipeLine(vtkMapper* theMapper){
+void
+SALOME_Actor
+::InitPipeLine(vtkMapper* theMapper)
+{
if(theMapper){
int anId = 0;
myPassFilter[ anId ]->SetInput( theMapper->GetInput() );
}
-void SALOME_Actor::Render(vtkRenderer *ren, vtkMapper* m){
+//----------------------------------------------------------------------------
+void
+ SALOME_Actor
+::Render(vtkRenderer *ren, vtkMapper* m)
+{
if(myIsResolveCoincidentTopology){
int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
float aFactor, aUnit;
}
-void SALOME_Actor::SetResolveCoincidentTopology(bool theIsResolve) {
+void
+SALOME_Actor
+::SetResolveCoincidentTopology(bool theIsResolve)
+{
myIsResolveCoincidentTopology = theIsResolve;
}
-void SALOME_Actor::SetPolygonOffsetParameters(float factor, float units){
+void
+SALOME_Actor
+::SetPolygonOffsetParameters(float factor, float units)
+{
myPolygonOffsetFactor = factor;
myPolygonOffsetUnits = units;
}
-void SALOME_Actor::GetPolygonOffsetParameters(float& factor, float& units){
+void
+SALOME_Actor::GetPolygonOffsetParameters(float& factor, float& units)
+{
factor = myPolygonOffsetFactor;
units = myPolygonOffsetUnits;
}
-vtkDataSet* SALOME_Actor::GetInput(){
+//----------------------------------------------------------------------------
+vtkDataSet*
+SALOME_Actor
+::GetInput()
+{
return myPassFilter.front()->GetOutput();
}
-unsigned long int SALOME_Actor::GetMTime(){
+unsigned long int
+SALOME_Actor
+::GetMTime()
+{
unsigned long mTime = this->Superclass::GetMTime();
unsigned long time = myTransformFilter->GetMTime();
mTime = ( time > mTime ? time : mTime );
}
-void SALOME_Actor::SetRepresentation(int theMode) {
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::SetRepresentation(int theMode)
+{
switch(myRepresentation){
case VTK_POINTS :
case VTK_SURFACE :
myRepresentation = theMode;
}
-int SALOME_Actor::GetRepresentation(){
+int
+SALOME_Actor
+::GetRepresentation()
+{
return myRepresentation;
}
-vtkCell* SALOME_Actor::GetElemCell(int theObjID){
+//----------------------------------------------------------------------------
+vtkCell*
+SALOME_Actor
+::GetElemCell(int theObjID)
+{
return GetInput()->GetCell(theObjID);
}
-float* SALOME_Actor::GetNodeCoord(int theObjID){
+float*
+SALOME_Actor::GetNodeCoord(int theObjID)
+{
return GetInput()->GetPoint(theObjID);
}
// purpose : Return object dimension.
// Virtual method shoulb be redifined by derived classes
//=================================================================================
-int SALOME_Actor::GetObjDimension( const int theObjId )
+int
+SALOME_Actor
+::GetObjDimension( const int theObjId )
{
if ( vtkCell* aCell = GetElemCell(theObjId) )
return aCell->GetCellDimension();
}
-bool SALOME_Actor::IsInfinitive(){
+bool
+SALOME_Actor
+::IsInfinitive()
+{
return myIsInfinite;
}
-void SALOME_Actor::SetOpacity(float theOpacity){
+void
+SALOME_Actor
+::SetOpacity(float theOpacity)
+{
myOpacity = theOpacity;
GetProperty()->SetOpacity(theOpacity);
}
-float SALOME_Actor::GetOpacity(){
+float
+SALOME_Actor
+::GetOpacity()
+{
return myOpacity;
}
-void SALOME_Actor::SetColor(float r,float g,float b){
+void
+SALOME_Actor
+::SetColor(float r,float g,float b)
+{
GetProperty()->SetColor(r,g,b);
}
-void SALOME_Actor::GetColor(float& r,float& g,float& b){
+void
+SALOME_Actor
+::GetColor(float& r,float& g,float& b)
+{
float aColor[3];
GetProperty()->GetColor(aColor);
r = aColor[0];
}
-int SALOME_Actor::getDisplayMode(){
+int
+SALOME_Actor
+::getDisplayMode()
+{
return myDisplayMode;
}
-void SALOME_Actor::setDisplayMode(int theMode){
+void
+SALOME_Actor::setDisplayMode(int theMode)
+{
SetRepresentation(theMode+1);
myDisplayMode = GetRepresentation() - 1;
}
-// from VISU
//----------------------------------------------------------------
-void SALOME_Actor::highlight( bool theHighlight, Selection_Mode theMode )
+void
+SALOME_Actor
+::highlight( bool theHighlight, Selection_Mode theMode )
{
- //cout << "SALOME_Actor::highlight " << ( theHighlight ? "on" : "off" ) << endl;
+ myIsHighlighted = theHighlight;
if( !GetVisibility() )
return;
}
//----------------------------------------------------------------
-void SALOME_Actor::SetVisibility( int theVisibility )
+void
+SALOME_Actor
+::SetVisibility( int theVisibility )
{
- //cout << "SALOME_Actor::SetVisibility " << ( theVisibility ? "on" : "off" ) << endl;
vtkProp::SetVisibility( theVisibility );
myOutlineActor->SetVisibility( theVisibility && isHighlighted() );
myHighlightActor->SetVisibility( theVisibility && isHighlighted() );
}
+
//----------------------------------------------------------------
-int SALOME_Actor::GetEdgeId( vtkPicker* thePicker, int theObjId )
+int
+SALOME_Actor
+::GetEdgeId( vtkPicker* thePicker, int theObjId )
{
int anEdgeId = -1;
if (vtkCell* aPickedCell = GetElemCell(theObjId)) {
return anEdgeId;
}
+
//----------------------------------------------------------------
-bool SALOME_Actor::PreHighlight( SVTK_InteractorStyle* theInteractorStyle,
- SVTK_Selector* theSelector,
- vtkRenderer* theRenderer,
- SVTK_SelectionEvent theSelectionEvent,
- bool theIsHighlight )
+bool
+SALOME_Actor
+::PreHighlight( VTK::TValidator* theValidator,
+ SVTK_Selector* theSelector,
+ vtkRenderer* theRenderer,
+ SVTK_SelectionEvent theSelectionEvent,
+ bool theIsHighlight )
{
Selection_Mode aSelectionMode = theSelectionEvent.SelectionMode;
float x = theSelectionEvent.X;
float y = theSelectionEvent.Y;
float z = 0.0;
- /*
- cout << "SALOME_Actor::PreHighlight" << endl;
- cout << "SelectionMode : ";
- switch( aSelectionMode )
- {
- case NodeSelection: cout << "Nodes" << endl; break;
- case CellSelection: cout << "Cells" << endl; break;
- case ActorSelection: cout << "Actor" << endl; break;
- default: cout << "Other" << endl; break;
- }
- cout << "IsHighlight : " << ( theIsHighlight ? "true" : "false" ) << endl;
- */
+
if( !theIsHighlight )
{
myPreHighlightActor->SetVisibility( false );
myPointPicker->Pick( x, y, z, theRenderer );
int aVtkId = myPointPicker->GetPointId();
- if( aVtkId >= 0 && theInteractorStyle->IsValid( this, aVtkId, true ) && hasIO() )
+ if( aVtkId >= 0 && theValidator->IsValid( this, aVtkId, true ) && hasIO() )
{
int anObjId = GetNodeObjId( aVtkId );
TColStd_IndexedMapOfInteger aMapIndex;
aMapIndex.Add( anObjId );
- //cout << "Index : " << anObjId << endl;
myPreHighlightActor->GetProperty()->SetRepresentationToPoints();
myPreHighlightActor->SetVisibility( true );
myCellPicker->Pick( x, y, z, theRenderer );
int aVtkId = myCellPicker->GetCellId();
- if ( aVtkId >= 0 && theInteractorStyle->IsValid( this, aVtkId ) && hasIO() )
+ if ( aVtkId >= 0 && theValidator->IsValid( this, aVtkId ) && hasIO() )
{
int anObjId = GetElemObjId (aVtkId );
TColStd_IndexedMapOfInteger aMapIndex;
aMapIndex.Add( anObjId );
- //cout << "Index : " << anObjId << endl;
myPreHighlightActor->GetProperty()->SetRepresentationToSurface();
myPreHighlightActor->SetVisibility( true );
myCellPicker->Pick( x, y, z, theRenderer );
int aVtkId = myCellPicker->GetCellId();
- if ( aVtkId >= 0 && theInteractorStyle->IsValid( this, aVtkId ) && hasIO() )
+ if ( aVtkId >= 0 && theValidator->IsValid( this, aVtkId ) && hasIO() )
{
int anObjId = GetElemObjId( aVtkId );
int anEdgeId = GetEdgeId( myCellPicker, anObjId );
TColStd_IndexedMapOfInteger aMapIndex;
aMapIndex.Add( anObjId );
aMapIndex.Add( anEdgeId );
- //cout << "Index : " << anObjId << " " << anEdgeId << endl;
myPreHighlightActor->GetProperty()->SetRepresentationToWireframe();
myPreHighlightActor->SetVisibility( true );
return true;
}
+
//----------------------------------------------------------------
-bool SALOME_Actor::Highlight( SVTK_InteractorStyle* theInteractorStyle,
- SVTK_Selector* theSelector,
- vtkRenderer* theRenderer,
- SVTK_SelectionEvent theSelectionEvent,
- bool theIsHighlight )
+bool
+SALOME_Actor
+::Highlight( VTK::TValidator* theValidator,
+ SVTK_Selector* theSelector,
+ vtkRenderer* theRenderer,
+ SVTK_SelectionEvent theSelectionEvent,
+ bool theIsHighlight )
{
Selection_Mode aSelectionMode = theSelectionEvent.SelectionMode;
float x1 = theSelectionEvent.X;
myPointPicker->Pick( x1, y1, z1, theRenderer );
int aVtkId = myPointPicker->GetPointId();
- if( aVtkId >= 0 && hasIO() && theInteractorStyle->IsValid( this, aVtkId, true ) )
+ if( aVtkId >= 0 && hasIO() && theValidator->IsValid( this, aVtkId, true ) )
{
int anObjId = GetNodeObjId( aVtkId );
if( anObjId >= 0 )
{
if( !isShift )
{
- theInteractorStyle->HighlightProp( NULL );
theSelector->ClearIObjects();
}
theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
myCellPicker->Pick( x1, y1, z1, theRenderer );
int aVtkId = myCellPicker->GetCellId();
- if( aVtkId >= 0 && hasIO() && theInteractorStyle->IsValid( this, aVtkId ) )
+ if( aVtkId >= 0 && hasIO() && theValidator->IsValid( this, aVtkId ) )
{
int anObjId = GetElemObjId( aVtkId );
if( anObjId >= 0 )
{
- //if( theInteractorStyle->CheckDimensionId( aSelectionMode, this, anObjId ) )
{
if( theSelector->IsSelected( myIO ) )
theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
{
if( !isShift )
{
- theInteractorStyle->HighlightProp( NULL );
theSelector->ClearIObjects();
}
theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
myCellPicker->Pick( x1, y1, z1, theRenderer );
int aVtkId = myCellPicker->GetCellId();
- if( aVtkId >= 0 && hasIO() && theInteractorStyle->IsValid( this, aVtkId ) )
+ if( aVtkId >= 0 && hasIO() && theValidator->IsValid( this, aVtkId ) )
{
int anObjId = GetElemObjId( aVtkId );
if( anObjId >= 0 )
{
if( !isShift )
{
- theInteractorStyle->HighlightProp( NULL );
theSelector->ClearIObjects();
}
- int anEdgeId = 0;//theInteractorStyle->GetEdgeId( myCellPicker, this, anObjId );
+ int anEdgeId = GetEdgeId( myCellPicker, anObjId );
if( anEdgeId >= 0 )
{
theSelector->AddOrRemoveIndex( myIO, anObjId, false );
{
if ( hasIO() )
{
- //theInteractorStyle->PropPicked++;
if( theSelector->IsSelected( myIO ) && isShift )
theSelector->RemoveIObject( this );
else
{
if( !isShift )
{
- theInteractorStyle->HighlightProp( NULL );
theSelector->ClearIObjects();
}
theSelector->AddIObject( this );
theRenderer->GetDisplayPoint( aPnt );
if( aPnt[0] > x2 && aPnt[0] < x1 && aPnt[1] > y1 && aPnt[1] < y2 )
- //if( theInteractorStyle->IsInRect( aPoint, x2, y2, x1, y1 ) )
{
float aDisp[3];
- //theInteractorStyle->ComputeWorldToDisplay( aPoint[0], aPoint[1] ,aPoint[2], aDisp );
theRenderer->SetWorldPoint( aPoint[0], aPoint[1], aPoint[2], 1.0 );
theRenderer->WorldToDisplay();
theRenderer->GetDisplayPoint( aDisp );
float aPickedPoint[3];
myPointPicker->GetMapperPosition( aPickedPoint );
vtkIdType aVtkId = aDataSet->FindPoint( aPickedPoint );
- if( aVtkId >= 0 && theInteractorStyle->IsValid( this, aVtkId, true ) )
+ if( aVtkId >= 0 && theValidator->IsValid( this, aVtkId, true ) )
{
int anObjId = GetNodeObjId( aVtkId );
anIndices.Add( anObjId );
for( it = cellList.begin(); it != cellList.end(); ++it )
{
int aCellId = (*it).cellId;
- if ( !theInteractorStyle->IsValid( this, aCellId ) )
+ if ( !theValidator->IsValid( this, aCellId ) )
continue;
int anObjId = GetElemObjId( aCellId );
if( anObjId != -1 )
{
- //if( CheckDimensionId( aSelectionMode, this ,anObjId ) )
anIndexes.Add( anObjId );
}
}
TColStd_IndexedMapOfInteger aMapIndex;
theSelector->GetIndex( getIO(), aMapIndex );
- /*
- cout << "SALOME_Actor::Highlight : ";
- for( int i = 1, n = aMapIndex.Extent(); i <= n; i++ )
- cout << aMapIndex(i) << " ";
- cout << endl;
- cout << "SelectionMode : ";
- switch( aSelectionMode )
- {
- case NodeSelection: cout << "Nodes" << endl; break;
- case CellSelection: cout << "Cells" << endl; break;
- case ActorSelection: cout << "Actor" << endl; break;
- default: cout << "Other" << endl; break;
- }
- cout << "IsRectangle : " << ( isRectangle ? "true" : "false" ) << endl;
- cout << "IsHighlight : " << ( theIsHighlight ? "true" : "false" ) << endl;
- */
switch( aSelectionMode )
{
return true;
}
-
-/*
-/// Checks: is the given Actor within display coordinates?
-bool
-SVTK_InteractorStyle
-::IsInRect(vtkActor* theActor,
- const int left, const int top,
- const int right, const int bottom)
-{
- float* aBounds = theActor->GetBounds();
- float aMin[3], aMax[3];
- ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
- ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
- if (aMin[0] > aMax[0]) {
- float aBuf = aMin[0];
- aMin[0] = aMax[0];
- aMax[0] = aBuf;
- }
- if (aMin[1] > aMax[1]) {
- float aBuf = aMin[1];
- aMin[1] = aMax[1];
- aMax[1] = aBuf;
- }
-
- return ((aMin[0]>left) && (aMax[0]<right) && (aMin[1]>bottom) && (aMax[1]<top));
-}
-
-
-/// Checks: is the given Cell within display coordinates?
-bool
-SVTK_InteractorStyle
-::IsInRect(vtkCell* theCell,
- const int left, const int top,
- const int right, const int bottom)
-{
- float* aBounds = theCell->GetBounds();
- float aMin[3], aMax[3];
- ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
- ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
- if (aMin[0] > aMax[0]) {
- float aBuf = aMin[0];
- aMin[0] = aMax[0];
- aMax[0] = aBuf;
- }
- if (aMin[1] > aMax[1]) {
- float aBuf = aMin[1];
- aMin[1] = aMax[1];
- aMax[1] = aBuf;
- }
-
- return ((aMin[0]>left) && (aMax[0]<right) && (aMin[1]>bottom) && (aMax[1]<top));
-}
-
-
-bool
-SVTK_InteractorStyle
-::IsInRect(float* thePoint,
- const int left, const int top,
- const int right, const int bottom)
-{
- float aPnt[3];
- ComputeWorldToDisplay(thePoint[0], thePoint[1], thePoint[2], aPnt);
-
- return ((aPnt[0]>left) && (aPnt[0]<right) && (aPnt[1]>bottom) && (aPnt[1]<top));
-}
-*/
#ifndef SALOME_ACTOR_H
#define SALOME_ACTOR_H
-#include "SALOME_InteractiveObject.hxx" // INCLUDES "using namespace std"
-#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
-#include "Handle_SALOME_InteractiveObject.hxx"
-#endif
+#include "SVTK_SelectionEvent.h"
+#include "SVTK_Selector.h"
+#include "SVTK.h"
-//#include <vtkLODActor.h> // INCLUDES "stdio.h"
-//#include <vtkProperty.h>
+#include "VTKViewer_Actor.h"
-// to overcome the conflict between std::ostream and io::ostream
-// the following variable must be defined:
-// VTK_USE_ANSI_STDLIB
+#include "SALOME_InteractiveObject.hxx"
+#include <string>
#include <vector>
class vtkCell;
class VTKViewer_PassThroughFilter;
class VTKViewer_CellRectPicker;
-extern int SALOME_POINT_SIZE;
-
-#ifdef WNT
-#define SALOME_OBJECT_EXPORT __declspec (dllexport)
-#else
-#define SALOME_OBJECT_EXPORT
-#endif
-
-#include <VTKViewer_Actor.h>
-
-#include "SVTK_Selector.h"
-#include "SVTK_SelectionEvent.h"
-
-#include <string>
-
class SVTK_Actor;
class SVTK_InteractorStyle;
-class SALOME_OBJECT_EXPORT SALOME_Actor : public VTKViewer_Actor {
+extern int SALOME_POINT_SIZE;
+
+class SALOME_Actor;
+
+namespace VTK
+{
+ struct TValidator
+ {
+ virtual
+ bool
+ IsValid( SALOME_Actor* theActor,
+ const int theId,
+ const bool theIsNode = false ) = 0;
+ };
+}
+
+class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
+{
public:
static SALOME_Actor* New();
-
+
vtkTypeMacro(SALOME_Actor,vtkLODActor);
- virtual Standard_Boolean hasIO() { return !myIO.IsNull(); }
- virtual const Handle(SALOME_InteractiveObject)& getIO() { return myIO; }
- virtual void setIO(const Handle(SALOME_InteractiveObject)& io) { myIO = io; }
+ virtual
+ Standard_Boolean
+ hasIO()
+ {
+ return !myIO.IsNull();
+ }
+
+ virtual
+ const Handle(SALOME_InteractiveObject)&
+ getIO()
+ {
+ return myIO;
+ }
+
+ virtual
+ void
+ setIO(const Handle(SALOME_InteractiveObject)& theIO)
+ {
+ myIO = theIO;
+ }
+
+ virtual
+ const char*
+ getName()
+ {
+ return myName.c_str();
+ }
- virtual const char* getName() { return myName.c_str(); }
- virtual void setName(const char* theName){
- if(hasIO()) myIO->setName(theName);
+ virtual
+ void
+ setName(const char* theName)
+ {
+ if(hasIO())
+ myIO->setName(theName);
myName = theName;
}
// To generate highlight automaticaly
- virtual bool hasHighlight() { return false; }
- //virtual void highlight(bool theHighlight) { myIsHighlighted = theHighlight; }
- virtual bool isHighlighted() { return myIsHighlighted; }
+ virtual
+ bool
+ hasHighlight()
+ {
+ return false;
+ }
+
+ virtual
+ void
+ highlight( bool, Selection_Mode );
+
+ virtual
+ void
+ highlight(bool theHighlight)
+ {
+ highlight(theHighlight,ActorSelection);
+ }
+
+ virtual
+ bool
+ isHighlighted()
+ {
+ return myIsHighlighted;
+ }
+
+ virtual
+ void
+ SetOpacity(float theOpacity);
+
+ virtual
+ float
+ GetOpacity();
- virtual void SetOpacity(float theOpacity);
- virtual float GetOpacity();
+ virtual
+ void
+ SetColor(float r,float g,float b);
- virtual void SetColor(float r,float g,float b);
- virtual void GetColor(float& r,float& g,float& b);
- void SetColor(const float theRGB[3]){
+ virtual
+ void
+ GetColor(float& r,float& g,float& b);
+
+ virtual
+ void
+ SetColor(const float theRGB[3])
+ {
SetColor(theRGB[0],theRGB[1],theRGB[2]);
}
vtkSetObjectMacro(PreviewProperty,vtkProperty);
- virtual void SetPreSelected(bool thePreselect = false) { myIsPreselected = thePreselect;}
+ virtual
+ void
+ SetPreSelected(bool thePreselect = false)
+ {
+ myIsPreselected = thePreselect;
+ }
// Used to obtain all dependent actors
- virtual void GetChildActors(vtkActorCollection*) {};
+ virtual
+ void
+ GetChildActors(vtkActorCollection*)
+ {};
- //virtual void AddToRender(vtkRenderer* theRenderer);
- //virtual void RemoveFromRender(vtkRenderer* theRenderer);
+ // For selection mapping purpose
+ virtual
+ int
+ GetNodeObjId(int theVtkID)
+ {
+ return theVtkID;
+ }
+ virtual
+ float*
+ GetNodeCoord(int theObjID);
- // For selection mapping purpose
- virtual int GetNodeObjId(int theVtkID) { return theVtkID;}
- virtual float* GetNodeCoord(int theObjID);
+ virtual
+ int
+ GetElemObjId(int theVtkID)
+ {
+ return theVtkID;
+ }
+
+ virtual
+ vtkCell*
+ GetElemCell(int theObjID);
- virtual int GetElemObjId(int theVtkID) { return theVtkID;}
- virtual vtkCell* GetElemCell(int theObjID);
+ virtual
+ int
+ GetObjDimension( const int theObjId );
- virtual int GetObjDimension( const int theObjId );
+ virtual
+ void
+ SetMapper(vtkMapper* theMapper);
- virtual void SetMapper(vtkMapper* theMapper);
- virtual vtkDataSet* GetInput();
+ virtual
+ vtkDataSet*
+ GetInput();
+ virtual
+ void
+ SetTransform(VTKViewer_Transform* theTransform);
- virtual void SetTransform(VTKViewer_Transform* theTransform);
- virtual unsigned long int GetMTime();
+ virtual
+ unsigned long int
+ GetMTime();
- virtual void SetRepresentation(int theMode);
- virtual int GetRepresentation();
+ virtual
+ void
+ SetRepresentation(int theMode);
- virtual int getDisplayMode();
- virtual void setDisplayMode(int theMode);
+ virtual
+ int
+ GetRepresentation();
+
+ virtual
+ int
+ getDisplayMode();
+
+ virtual
+ void
+ setDisplayMode(int theMode);
// Infinitive means actor without size (point for example),
// which is not taken into account in calculation of boundaries of the scene
- void SetInfinitive(bool theIsInfinite) { myIsInfinite = theIsInfinite; }
- virtual bool IsInfinitive();
+ void
+ SetInfinitive(bool theIsInfinite)
+ {
+ myIsInfinite = theIsInfinite;
+ }
+
+ virtual
+ bool
+ IsInfinitive();
- void SetResolveCoincidentTopology(bool theIsResolve);
- void SetPolygonOffsetParameters(float factor, float units);
- void GetPolygonOffsetParameters(float& factor, float& units);
+ void
+ SetResolveCoincidentTopology(bool theIsResolve);
+
+ void
+ SetPolygonOffsetParameters(float factor, float units);
+
+ void
+ GetPolygonOffsetParameters(float& factor, float& units);
+
+ virtual
+ void
+ Render(vtkRenderer *, vtkMapper *);
+
+ virtual
+ float
+ GetShrinkFactor()
+ {
+ return 1.0;
+ }
+
+ virtual
+ bool
+ IsShrunkable()
+ {
+ return false;
+ }
+
+ virtual
+ bool
+ IsShrunk()
+ {
+ return false;
+ }
+
+ virtual
+ void
+ SetShrink()
+ {}
+
+ virtual
+ void
+ UnShrink()
+ {}
+
+ virtual
+ bool
+ IsSetCamera() const
+ {
+ return false;
+ }
- virtual void Render(vtkRenderer *, vtkMapper *);
+ virtual
+ bool
+ IsResizable() const
+ {
+ return false;
+ }
+
+ virtual
+ void
+ SetSize( const float )
+ {}
+
+ virtual
+ void
+ SetCamera( vtkCamera* )
+ {}
+
+ virtual
+ void
+ SetVisibility( int );
+
+ virtual
+ void
+ AddToRender( vtkRenderer* );
+
+ virtual
+ void
+ RemoveFromRender( vtkRenderer* );
+
+ virtual
+ bool
+ PreHighlight( VTK::TValidator*,
+ SVTK_Selector*,
+ vtkRenderer*,
+ SVTK_SelectionEvent,
+ bool );
+ virtual
+ bool
+ Highlight( VTK::TValidator*,
+ SVTK_Selector*,
+ vtkRenderer*,
+ SVTK_SelectionEvent,
+ bool );
+
+ vtkProperty*
+ getPointProperty()
+ {
+ return myPointProperty;
+ }
- virtual float GetShrinkFactor() { return 1.0;}
+ vtkProperty*
+ getCellProperty()
+ {
+ return myCellProperty;
+ }
- virtual bool IsShrunkable() { return false;}
- virtual bool IsShrunk() { return false;}
+ vtkProperty*
+ getEdgeProperty()
+ {
+ return myEdgeProperty;
+ }
- virtual void SetShrink() {}
- virtual void UnShrink() {}
+ vtkPointPicker*
+ getPointPicker()
+ {
+ return myPointPicker;
+ }
- virtual bool IsSetCamera() const { return false; }
- virtual bool IsResizable() const { return false; }
- virtual void SetSize( const float ) {}
- virtual void SetCamera( vtkCamera* ) {}
+ vtkCellPicker*
+ getCellPicker()
+ {
+ return myCellPicker;
+ }
+
+ VTKViewer_CellRectPicker*
+ getCellRectPicker()
+ {
+ return myCellRectPicker;
+ }
protected:
bool myIsResolveCoincidentTopology;
int myRepresentation;
vtkProperty *myProperty;
- void InitPipeLine(vtkMapper* theMapper);
+ void
+ InitPipeLine(vtkMapper* theMapper);
SALOME_Actor();
~SALOME_Actor();
// From VISU
public:
- virtual void highlight( bool, Selection_Mode );
-
- virtual void SetVisibility( int );
-
- virtual void AddToRender( vtkRenderer* );
- virtual void RemoveFromRender( vtkRenderer* );
-
- virtual bool PreHighlight( SVTK_InteractorStyle*, SVTK_Selector*, vtkRenderer*, SVTK_SelectionEvent, bool );
- virtual bool Highlight( SVTK_InteractorStyle*, SVTK_Selector*, vtkRenderer*, SVTK_SelectionEvent, bool );
-
- vtkProperty* getPointProperty() const { return myPointProperty; }
- vtkProperty* getCellProperty() const { return myCellProperty; }
- vtkProperty* getEdgeProperty() const { return myEdgeProperty; }
-
- vtkPointPicker* getPointPicker() const { return myPointPicker; }
- vtkCellPicker* getCellPicker() const { return myCellPicker; }
- VTKViewer_CellRectPicker* getCellRectPicker() const { return myCellRectPicker; }
protected:
int GetEdgeId( vtkPicker*, int );
- /*
- bool IsInRect(vtkActor* theActor,
- const int left, const int top,
- const int right, const int bottom);
- bool IsInRect(vtkCell* theCell,
- const int left, const int top,
- const int right, const int bottom);
- bool IsInRect(float* thePoint,
- const int left, const int top,
- const int right, const int bottom);
- */
- protected:
vtkProperty* myPointProperty;
vtkProperty* myCellProperty;
vtkProperty* myEdgeProperty;
#include "SVTK_InteractorStyle.h"
-#include "utilities.h"
-
-#include "VTKViewer_CellRectPicker.h"
#include "VTKViewer_Utilities.h"
#include "VTKViewer_RectPicker.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "SALOME_ListIO.hxx"
-#include "SUIT_Session.h"
-#include "CAM_Application.h"
-
#include <vtkObjectFactory.h>
#include <vtkMath.h>
#include <vtkCommand.h>
#include <vtkCamera.h>
#include <vtkRenderer.h>
#include <vtkPicker.h>
-#include <vtkPointPicker.h>
-#include <vtkCellPicker.h>
-#include <vtkLine.h>
-#include <vtkMapper.h>
-#include <vtkDataSet.h>
-#include <vtkSmartPointer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
//VRV: porting on Qt 3.0.5
#include <algorithm>
-using namespace std;
+#include "utilities.h"
+using namespace std;
#ifdef _DEBUG_
static int MYDEBUG = 0;
this->ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE;
loadCursors();
- OnSelectionModeChanged();
+ myPicker = vtkPicker::New();
+ myPicker->Delete();
+
+ myRectPicker = VTKViewer_RectPicker::New();
+ myRectPicker->Delete();
}
//----------------------------------------------------------------------------
return myViewWindow->GetSelector();
}
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorStyle
-::setPreselectionProp(const double& theRed,
- const double& theGreen,
- const double& theBlue,
- const int& theWidth)
-{
- /*
- if ( myPreSelectionActor->GetProperty() == 0 )
- return;
- myPreSelectionActor->GetProperty()->SetColor(theRed, theGreen, theBlue);
- myPreSelectionActor->GetProperty()->SetLineWidth(theWidth);
- myPreSelectionActor->GetProperty()->SetPointSize(theWidth);
- */
-}
-
//----------------------------------------------------------------------------
int
SVTK_InteractorStyle
SVTK_InteractorStyle
::OnMouseMove()
{
- //cout << "SVTK_InteractorStyle::OnMouseMove" << endl;
-
int x, y;
this->Interactor->GetEventPosition( x, y );
this->OnMouseMove( this->Interactor->GetControlKey(),
SVTK_InteractorStyle
::OnLeftButtonDown()
{
- //cout << "SVTK_InteractorStyle::OnLeftButtonDown" << endl;
-
int x, y;
this->Interactor->GetEventPosition( x, y );
this->OnLeftButtonDown( this->Interactor->GetControlKey(),
SVTK_InteractorStyle
::OnLeftButtonUp()
{
- //cout << "SVTK_InteractorStyle::OnLeftButtonUp" << endl;
-
int x, y;
this->Interactor->GetEventPosition( x, y );
this->OnLeftButtonUp( this->Interactor->GetControlKey(),
SVTK_InteractorStyle
::OnMiddleButtonDown()
{
- //cout << "SVTK_InteractorStyle::OnMiddleButtonDown" << endl;
-
int x, y;
this->Interactor->GetEventPosition( x, y );
this->OnMiddleButtonDown( this->Interactor->GetControlKey(),
SVTK_InteractorStyle
::OnMiddleButtonUp()
{
- //cout << "SVTK_InteractorStyle::OnMiddleButtonUp" << endl;
-
int x, y;
this->Interactor->GetEventPosition( x, y );
this->OnMiddleButtonUp( this->Interactor->GetControlKey(),
SVTK_InteractorStyle
::OnRightButtonDown()
{
- //cout << "SVTK_InteractorStyle::OnRightButtonDown" << endl;
-
int x, y;
this->Interactor->GetEventPosition( x, y );
this->OnRightButtonDown( this->Interactor->GetControlKey(),
SVTK_InteractorStyle
::OnRightButtonUp()
{
- //cout << "SVTK_InteractorStyle::OnRightButtonUp" << endl;
-
int x, y;
this->Interactor->GetEventPosition( x, y );
this->OnRightButtonUp( this->Interactor->GetControlKey(),
// rwi->GetRenderWindow()->SetDesiredUpdateRate(rwi->GetStillUpdateRate());
Selection_Mode aSelectionMode = myViewWindow->SelectionMode();
- bool aSelActiveCompOnly = false;
-
- QString aComponentDataType;
- if(SUIT_Session* aSession = SUIT_Session::session())
- if(SUIT_Application* aSUITApp = aSession->activeApplication())
- if(CAM_Application* aCAMApp = dynamic_cast<CAM_Application*>(aSUITApp))
- if(CAM_Module* aModule = aCAMApp->activeModule())
- aComponentDataType = aModule->name();
switch (State) {
case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
this->FindPokedRenderer(x, y);
Interactor->StartPickCallback();
- vtkPicker* aPicker = vtkPicker::SafeDownCast(Interactor->GetPicker());
- aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
-
- SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
-
- SVTK_SelectionEvent aSelectionEvent = GetSelectionEvent();
- aSelectionEvent.SelectionMode = aSelectionMode;
- aSelectionEvent.IsRectangle = false;
-
- if( aSActor )
+ myPicker->Pick(x, y, 0.0, this->CurrentRenderer);
+ if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(myPicker->GetActor())){
+ SVTK_SelectionEvent aSelectionEvent = GetSelectionEvent();
+ aSelectionEvent.SelectionMode = aSelectionMode;
+ aSelectionEvent.IsRectangle = false;
aSActor->Highlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
- else
- {
- this->HighlightProp( NULL );
+ }else{
GetSelector()->ClearIObjects();
}
} else {
//processing rectangle selection
- if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return;
Interactor->StartPickCallback();
if (!myShiftState) {
x2 = rect.right();
y2 = h - rect.bottom() - 1;
+ myRectPicker->SetTolerance(0.001);
+ myRectPicker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
+
SVTK_SelectionEvent aSelectionEvent = GetSelectionEvent();
aSelectionEvent.SelectionMode = aSelectionMode;
aSelectionEvent.IsRectangle = true;
aSelectionEvent.LastX = x1;
aSelectionEvent.LastY = y1;
- vtkSmartPointer<VTKViewer_RectPicker> aPicker = VTKViewer_RectPicker::New();
- aPicker->SetTolerance(0.001);
- aPicker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
-
- vtkActorCollection* aListActors = aPicker->GetActors();
+ vtkActorCollection* aListActors = myRectPicker->GetActors();
aListActors->InitTraversal();
while(vtkActor* aActor = aListActors->GetNextActor()){
if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)){
this->LastPos[1] = h - mousePos.y() - 1;
}
-// called when selection mode changed (!put necessary initialization here!)
-void
-SVTK_InteractorStyle
-::OnSelectionModeChanged()
-{
-
- myElemId = myEdgeId = myNodeId = -1;
- mySelectedActor = NULL;
-}
-
// called when user moves mouse inside viewer window and there is no active viewer operation
// (!put necessary processing here!)
void
::onCursorMove(QPoint mousePos)
{
// processing highlighting
- Selection_Mode aSelectionMode = myViewWindow->SelectionMode();
-
int w, h, x, y;
Interactor->GetSize(w, h);
x = mousePos.x(); y = h - mousePos.y() - 1;
this->FindPokedRenderer(x,y);
Interactor->StartPickCallback();
- vtkPicker* aPicker = vtkPicker::SafeDownCast(Interactor->GetPicker());
-
- SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
-
SVTK_SelectionEvent aSelectionEvent = GetSelectionEvent();
+ aSelectionEvent.SelectionMode = myViewWindow->SelectionMode();
aSelectionEvent.X = x;
aSelectionEvent.Y = y;
- aSelectionEvent.SelectionMode = aSelectionMode;
- if( aSActor )
+ if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(myPicker->GetActor()))
aSActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, false );
- //cout << "onCursorMove : " << ( aSActor ? "1" : "0" ) << " ";
- aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
-
- aSActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
- //cout << ( aSActor ? "1" : "0" ) << endl;
-
- if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
- if ( aSActor )
- aSActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
- }
- else if (vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker)) {
- if ( aSActor )
- aSActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
- }
- else if ( vtkPicker::SafeDownCast(aPicker) ) {
- if( aSActor )
- aSActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
- /*
- else {
- myPreViewActor = NULL;
- vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
- theActors->InitTraversal();
- while( vtkActor *ac = theActors->GetNextActor() ) {
- if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
- anActor->SetPreSelected( false );
- }
- }
- }
- */
- }
+ myPicker->Pick(x, y, 0.0, this->CurrentRenderer);
+ if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(myPicker->GetActor()))
+ aSActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
+
Interactor->EndPickCallback();
//Interactor->Render();
myGUIWindow->update();
#include "SVTK.h"
#include <vtkInteractorStyle.h>
-
-class vtkCell;
-class vtkRenderWindowInteractor;
+#include <vtkSmartPointer.h>
#include <qobject.h>
#include <qcursor.h>
#include "VTKViewer_Filter.h"
#include "SVTK_SelectionEvent.h"
+#include "SALOME_Actor.h"
-class VTKViewer_Trihedron;
+class vtkPicker;
+class VTKViewer_RectPicker;
class SALOME_Actor;
class SVTK_Viewer;
#define VTK_INTERACTOR_STYLE_CAMERA_SELECT 6
#define VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN 7
-class SVTK_EXPORT SVTK_InteractorStyle : public QObject,
+class SVTK_EXPORT SVTK_InteractorStyle :
+ public QObject,
+ public VTK::TValidator,
public vtkInteractorStyle
{
- Q_OBJECT
+ Q_OBJECT;
public:
// Description:
SVTK_SelectionEvent GetSelectionEvent();
- //merge with V2_2_0_VISU_improvements:void setTriedron(VTKViewer_Trihedron* theTrihedron);
- void setPreselectionProp(const double& theRed = 0,
- const double& theGreen = 1,
- const double& theBlue = 1,
- const int& theWidth = 5);
-
// VTK events
virtual void OnMouseMove();
virtual void OnLeftButtonDown();
void OnRightButtonDown(int ctrl, int shift, int x, int y);
void OnRightButtonUp (int ctrl, int shift, int x, int y);
- void OnSelectionModeChanged();
+ void
+ SetFilter( const Handle(VTKViewer_Filter)& );
+
+ Handle(VTKViewer_Filter)
+ GetFilter( const int );
- //merge with V2_2_0_VISU_improvements:void ViewFitAll();
+ bool
+ IsFilterPresent( const int );
- void SetFilter( const Handle(VTKViewer_Filter)& );
- Handle(VTKViewer_Filter) GetFilter( const int );
- bool IsFilterPresent( const int );
- void RemoveFilter( const int );
- bool IsValid( SALOME_Actor* theActor,
- const int theId,
- const bool theIsNode = false );
+ void
+ RemoveFilter( const int );
+
+ bool
+ IsValid( SALOME_Actor* theActor,
+ const int theId,
+ const bool theIsNode = false );
- void IncrementalPan ( const int incrX, const int incrY );
- void IncrementalZoom ( const int incr );
- void IncrementalRotate( const int incrX, const int incrY );
+ void
+ IncrementalPan( const int incrX, const int incrY );
+
+ void
+ IncrementalZoom( const int incr );
+
+ void
+ IncrementalRotate( const int incrX, const int incrY );
protected:
SVTK_InteractorStyle();
float RadianToDegree; // constant: for conv from deg to rad
double myScale;
- SALOME_Actor* myPreViewActor;
-
- SALOME_Actor* mySelectedActor;
- int myElemId;
- int myEdgeId;
- int myNodeId;
-
public:
bool eventFilter(QObject* object, QEvent* event);
void startZoom();
signals:
void RenderWindowModified() ;
- void contextMenuRequested( QContextMenuEvent *e );
protected:
QCursor myDefCursor;
int ForcedState;
SVTK_ViewWindow* myViewWindow;
- //merge with V2_2_0_VISU_improvements:VTKViewer_Trihedron* myTrihedron;
QWidget* myGUIWindow;
+
+ vtkSmartPointer<vtkPicker> myPicker;
+ vtkSmartPointer<VTKViewer_RectPicker> myRectPicker;
std::map<int, Handle(VTKViewer_Filter)> myFilters;