// VTK Includes
#include <vtkCell.h>
+#include <vtkLine.h>
#include <vtkPicker.h>
#include <vtkPointPicker.h>
#include <vtkCellPicker.h>
myPassFilter.push_back(VTKViewer_PassThroughFilter::New());
// from VISU
+ myPointPicker = vtkPointPicker::New();
+ myCellPicker = vtkCellPicker::New();
+ myCellRectPicker = VTKViewer_CellRectPicker::New();
+
myPreHighlightActor = SVTK_Actor::New();
myPreHighlightActor->GetProperty()->SetColor(0,1,0);
myPreHighlightActor->GetProperty()->SetPointSize(15);
myProperty->Delete();
// from VISU
+ myPointPicker->Delete();
+ myCellPicker->Delete();
+ myCellRectPicker->Delete();
myHighlightActor->SetProperty( NULL );
}
//----------------------------------------------------------------
void SALOME_Actor::SetVisibility( int theVisibility )
{
+ cout << "SALOME_Actor::SetVisibility " << ( theVisibility ? "on" : "off" ) << endl;
vtkProp::SetVisibility( theVisibility );
myHighlightActor->SetVisibility( theVisibility && isHighlighted() );
}
//----------------------------------------------------------------
-bool SALOME_Actor::PreHighlight( SVTK_InteractorStyle* theInteractorStyle,
- const int& theIndex )
+int SALOME_Actor::GetEdgeId( vtkPicker* thePicker, int theObjId )
{
- //cout << "SALOME_Actor::PreHighlight : " << theIndex << endl;
+ int anEdgeId = -1;
+ if (vtkCell* aPickedCell = GetElemCell(theObjId)) {
+ float aPickPosition[3];
+ thePicker->GetPickPosition(aPickPosition);
+ float aMinDist = 1000000.0, aDist = 0;
+ for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
+ if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){
+ int subId; float pcoords[3], closestPoint[3], weights[3];
+ aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
+ if (aDist < aMinDist) {
+ aMinDist = aDist;
+ anEdgeId = i;
+ }
+ }
+ }
+ }
+ return anEdgeId;
+}
- if( theIndex == -1 )
+//----------------------------------------------------------------
+bool SALOME_Actor::PreHighlight( SVTK_InteractorStyle* theInteractorStyle,
+ 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 );
+
+ vtkActorCollection* theActors = theRenderer->GetActors();
+ theActors->InitTraversal();
+ while( vtkActor *ac = theActors->GetNextActor() )
+ if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) )
+ anActor->SetPreSelected( false );
+
+ return false;
}
- else
+
+ if( aSelectionMode == NodeSelection )
{
- TColStd_IndexedMapOfInteger aMapIndex;
- aMapIndex.Add( theIndex );
+ myPointPicker->Pick( x, y, z, theRenderer );
- myPreHighlightActor->SetVisibility( true );
- myPreHighlightActor->MapPoints( this, aMapIndex );
+ int aVtkId = myPointPicker->GetPointId();
+ if( aVtkId >= 0 && theInteractorStyle->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 );
+ myPreHighlightActor->MapPoints( this, aMapIndex );
+ }
}
+ else if( aSelectionMode == CellSelection )
+ {
+ myCellPicker->Pick( x, y, z, theRenderer );
- return false;
+ int aVtkId = myCellPicker->GetCellId();
+ if ( aVtkId >= 0 && theInteractorStyle->IsValid( this, aVtkId ) && hasIO() )
+ {
+ int anObjId = GetElemObjId (aVtkId );
+ TColStd_IndexedMapOfInteger aMapIndex;
+ aMapIndex.Add( anObjId );
+ //cout << "Index : " << anObjId << endl;
+
+ myPreHighlightActor->GetProperty()->SetRepresentationToSurface();
+ myPreHighlightActor->SetVisibility( true );
+ myPreHighlightActor->MapCells( this, aMapIndex );
+ }
+ }
+ else if( aSelectionMode == EdgeOfCellSelection )
+ {
+ myCellPicker->Pick( x, y, z, theRenderer );
+
+ int aVtkId = myCellPicker->GetCellId();
+ if ( aVtkId >= 0 && theInteractorStyle->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 );
+ myPreHighlightActor->MapEdge( this, aMapIndex );
+ }
+ }
+ else
+ {
+ if( hasIO() && !theSelector->IsSelected( myIO ) )
+ {
+ vtkActorCollection* theActors = theRenderer->GetActors();
+ theActors->InitTraversal();
+ while( vtkActor *ac = theActors->GetNextActor() )
+ {
+ if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) )
+ if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
+ anActor->SetPreSelected( true );
+ }
+ }
+ }
+
+ return true;
}
//----------------------------------------------------------------
SVTK_Selector* theSelector,
vtkRenderer* theRenderer,
SVTK_SelectionEvent theSelectionEvent,
- bool theIsHighlight,
- bool theIsUpdate )
+ bool theIsHighlight )
{
Selection_Mode aSelectionMode = theSelectionEvent.SelectionMode;
float x1 = theSelectionEvent.X;
float z2 = 0.0;
bool isShift = theSelectionEvent.IsShift;
bool isRectangle = theSelectionEvent.IsRectangle;
- /*
- cout << x1 << " " << y1;
- if( isRectangle )
- cout << " " << x2 << " " << y2;
- cout << endl;
- */
+
if( !isRectangle )
{
if( aSelectionMode == NodeSelection )
{
- vtkPointPicker* aPicker = vtkPointPicker::New();
- aPicker->Pick( x1, y1, z1, theRenderer );
+ myPointPicker->Pick( x1, y1, z1, theRenderer );
- int aVtkId = aPicker->GetPointId();
+ int aVtkId = myPointPicker->GetPointId();
if( aVtkId >= 0 && hasIO() && theInteractorStyle->IsValid( this, aVtkId, true ) )
{
int anObjId = GetNodeObjId( aVtkId );
}
}
}
- aPicker->Delete();
}
else if( aSelectionMode == CellSelection )
{
- vtkCellPicker* aPicker = vtkCellPicker::New();
- aPicker->Pick( x1, y1, z1, theRenderer );
+ myCellPicker->Pick( x1, y1, z1, theRenderer );
- int aVtkId = aPicker->GetCellId();
+ int aVtkId = myCellPicker->GetCellId();
if( aVtkId >= 0 && hasIO() && theInteractorStyle->IsValid( this, aVtkId ) )
{
int anObjId = GetElemObjId( aVtkId );
}
}
}
- aPicker->Delete();
}
else if( aSelectionMode == EdgeOfCellSelection )
{
- vtkCellPicker* aPicker = vtkCellPicker::New();
- aPicker->Pick( x1, y1, z1, theRenderer );
+ myCellPicker->Pick( x1, y1, z1, theRenderer );
- int aVtkId = aPicker->GetCellId();
+ int aVtkId = myCellPicker->GetCellId();
if( aVtkId >= 0 && hasIO() && theInteractorStyle->IsValid( this, aVtkId ) )
{
int anObjId = GetElemObjId( aVtkId );
theInteractorStyle->HighlightProp( NULL );
theSelector->ClearIObjects();
}
- int anEdgeId = 0;//theInteractorStyle->GetEdgeId( aPicker, this, anObjId );
+ int anEdgeId = 0;//theInteractorStyle->GetEdgeId( myCellPicker, this, anObjId );
if( anEdgeId >= 0 )
{
theSelector->AddOrRemoveIndex( myIO, anObjId, false );
}
}
}
- aPicker->Delete();
}
else if( aSelectionMode == ActorSelection )
{
{
if( aSelectionMode == NodeSelection && hasIO() && !myIO.IsNull() )
{
- vtkPointPicker* aPicker = vtkPointPicker::New();
if( vtkDataSet* aDataSet = GetInput() )
{
TColStd_MapOfInteger anIndices;
theRenderer->WorldToDisplay();
theRenderer->GetDisplayPoint( aDisp );
- if( aPicker->Pick( aDisp[0], aDisp[1], 0.0, theRenderer ) )
+ if( myPointPicker->Pick( aDisp[0], aDisp[1], 0.0, theRenderer ) )
{
- if( vtkActorCollection* anActorCollection = aPicker->GetActors() )
+ if( vtkActorCollection* anActorCollection = myPointPicker->GetActors() )
{
if( anActorCollection->IsItemPresent( this ) )
{
float aPickedPoint[3];
- aPicker->GetMapperPosition( aPickedPoint );
+ myPointPicker->GetMapperPosition( aPickedPoint );
vtkIdType aVtkId = aDataSet->FindPoint( aPickedPoint );
if( aVtkId >= 0 && theInteractorStyle->IsValid( this, aVtkId, true ) )
{
else
theSelector->RemoveIObject( this );
}
- aPicker->Delete();
}
else if( aSelectionMode != ActorSelection && hasIO() )
{
- VTKViewer_CellRectPicker* aPicker = VTKViewer_CellRectPicker::New();
- aPicker->SetTolerance( 0.001 );
- aPicker->Pick( x2, y2, z2, x1, y1, z1, theRenderer );
+ myCellRectPicker->SetTolerance( 0.001 );
+ myCellRectPicker->Pick( x2, y2, z2, x1, y1, z1, theRenderer );
- VTKViewer_CellDataSet cellList = aPicker->GetCellData( this );
+ VTKViewer_CellDataSet cellList = myCellRectPicker->GetCellData( this );
TColStd_MapOfInteger anIndexes;
if( !cellList.empty() )
{
}
theSelector->AddOrRemoveIndex( myIO, anIndexes, true );
theSelector->AddIObject( this );
-
- aPicker->Delete();
}
else if( aSelectionMode == ActorSelection && hasIO() )
{
}
cout << "IsRectangle : " << ( isRectangle ? "true" : "false" ) << endl;
cout << "IsHighlight : " << ( theIsHighlight ? "true" : "false" ) << endl;
- cout << "IsUpdate : " << ( theIsUpdate ? "true" : "false" ) << endl;
*/
+
if( GetVisibility() && theIsHighlight )
theInteractorStyle->HighlightProp( this );
else if( !theIsHighlight )
theInteractorStyle->HighlightProp( NULL );
- //if( aSelectionMode != ActorSelection && !hasHighlight() )
- // return false;
-
switch( aSelectionMode )
{
case NodeSelection:
break;
}
- return false;
-}
-
-//----------------------------------------------------------------
-bool SALOME_Actor::Unhighlight( SVTK_InteractorStyle* theInteractorStyle,
- SVTK_Selector* theSelector,
- bool theIsUpdate )
-{
-
- theInteractorStyle->HighlightProp( NULL );
- theSelector->ClearIObjects();
+ return true;
}
/*
#include <vector>
class vtkCell;
+class vtkPicker;
+class vtkPointPicker;
+class vtkCellPicker;
class vtkDataSet;
class vtkPolyData;
class vtkCamera;
class VTKViewer_GeometryFilter;
class VTKViewer_TransformFilter;
class VTKViewer_PassThroughFilter;
+class VTKViewer_CellRectPicker;
extern int SALOME_POINT_SIZE;
virtual void AddToRender( vtkRenderer* );
virtual void RemoveFromRender( vtkRenderer* );
- virtual bool PreHighlight( SVTK_InteractorStyle*, const int& );
+ 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; }
- virtual bool Highlight( SVTK_InteractorStyle*, SVTK_Selector*, vtkRenderer*, SVTK_SelectionEvent, bool, bool );
- virtual bool Unhighlight( SVTK_InteractorStyle*, SVTK_Selector*, bool );
- /*
protected:
+ int GetEdgeId( vtkPicker*, int );
+
+ /*
bool IsInRect(vtkActor* theActor,
const int left, const int top,
const int right, const int bottom);
vtkProperty* myCellProperty;
vtkProperty* myEdgeProperty;
+ vtkPointPicker* myPointPicker;
+ vtkCellPicker* myCellPicker;
+ VTKViewer_CellRectPicker* myCellRectPicker;
+
SVTK_Actor* myPreHighlightActor;
SVTK_Actor* myHighlightActor;
};
-
#endif // SALOME_ACTOR_H
-
#include "VTKViewer_Utilities.h"
#include "VTKViewer_RectPicker.h"
-#include "SVTK_RenderWindowInteractor.h"
#include "SVTK_RenderWindow.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_Selection.h"
#include "SALOME_Actor.h"
-#include "SVTK_Actor.h"
#include "SVTK_Selector.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include <vtkDataSet.h>
#include <vtkSmartPointer.h>
#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
#include <qapplication.h>
//VRV: porting on Qt 3.0.5
namespace
{
- int
- GetEdgeId(vtkPicker *thePicker, SALOME_Actor *theActor, int theObjId)
- {
- int anEdgeId = -1;
- if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) {
- float aPickPosition[3];
- thePicker->GetPickPosition(aPickPosition);
- float aMinDist = 1000000.0, aDist = 0;
- for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
- if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){
- int subId; float pcoords[3], closestPoint[3], weights[3];
- aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
- if (aDist < aMinDist) {
- aMinDist = aDist;
- anEdgeId = i;
- }
- }
- }
- }
- return anEdgeId;
- }
-
-
-
bool CheckDimensionId(Selection_Mode theMode, SALOME_Actor *theActor, vtkIdType theObjId){
switch(theMode){
case CellSelection:
this->ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE;
loadCursors();
- myPreSelectionActor = SVTK_Actor::New();
- myPreSelectionActor->GetProperty()->SetColor(0,1,1);
- myPreSelectionActor->GetProperty()->SetLineWidth(5);
- myPreSelectionActor->GetProperty()->SetPointSize(5);
-
OnSelectionModeChanged();
}
::~SVTK_InteractorStyle()
{
if(MYDEBUG) INFOS("SVTK_InteractorStyle::~SVTK_InteractorStyle()");
- myViewWindow->RemoveActor(myPreSelectionActor);
}
//----------------------------------------------------------------------------
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);
+ */
}
//----------------------------------------------------------------------------
-void
+int
SVTK_InteractorStyle
-::SetInteractor(vtkRenderWindowInteractor *theInteractor)
+::GetState()
{
- myInteractor = dynamic_cast<SVTK_RenderWindowInteractor*>(theInteractor);
- Superclass::SetInteractor(theInteractor);
+ return State | ForcedState;
}
//----------------------------------------------------------------------------
-int
+SVTK_SelectionEvent
SVTK_InteractorStyle
-::GetState()
+::GetSelectionEvent()
{
- return State | ForcedState;
+ SVTK_SelectionEvent aSelectionEvent;
+
+ int x, y, w, h;
+ Interactor->GetEventPosition( x, y );
+ Interactor->GetSize( w, h );
+
+ aSelectionEvent.X = x;
+ aSelectionEvent.Y = h - y - 1;
+ aSelectionEvent.IsCtrl = Interactor->GetControlKey();
+ aSelectionEvent.IsShift = Interactor->GetShiftKey();
+
+ return aSelectionEvent;
}
//----------------------------------------------------------------------------
::setViewWindow(SVTK_ViewWindow* theViewWindow)
{
myViewWindow = theViewWindow;
- myViewWindow->AddActor(myPreSelectionActor);
- myPreSelectionActor->Delete();
}
//----------------------------------------------------------------------------
}
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::OnMouseMove()
+{
+ //cout << "void SVTK_InteractorStyle::OnMouseMove()" << endl;
+
+ int x, y;
+ this->Interactor->GetEventPosition( x, y );
+ this->OnMouseMove( this->Interactor->GetControlKey(),
+ this->Interactor->GetShiftKey(),
+ x, y );
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::OnLeftButtonDown()
+{
+ //cout << "void SVTK_InteractorStyle::OnLeftButtonDown()" << endl;
+
+ int x, y;
+ this->Interactor->GetEventPosition( x, y );
+ this->OnLeftButtonDown( this->Interactor->GetControlKey(),
+ this->Interactor->GetShiftKey(),
+ x, y );
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::OnLeftButtonUp()
+{
+ //cout << "void SVTK_InteractorStyle::OnLeftButtonUp()" << endl;
+
+ int x, y;
+ this->Interactor->GetEventPosition( x, y );
+ this->OnLeftButtonUp( this->Interactor->GetControlKey(),
+ this->Interactor->GetShiftKey(),
+ x, y );
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::OnMiddleButtonDown()
+{
+ //cout << "void SVTK_InteractorStyle::OnMiddleButtonDown()" << endl;
+
+ int x, y;
+ this->Interactor->GetEventPosition( x, y );
+ this->OnMiddleButtonDown( this->Interactor->GetControlKey(),
+ this->Interactor->GetShiftKey(),
+ x, y );
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::OnMiddleButtonUp()
+{
+ //cout << "void SVTK_InteractorStyle::OnMiddleButtonUp()" << endl;
+
+ int x, y;
+ this->Interactor->GetEventPosition( x, y );
+ this->OnMiddleButtonUp( this->Interactor->GetControlKey(),
+ this->Interactor->GetShiftKey(),
+ x, y );
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::OnRightButtonDown()
+{
+ //cout << "void SVTK_InteractorStyle::OnRightButtonDown()" << endl;
+
+ int x, y;
+ this->Interactor->GetEventPosition( x, y );
+ this->OnRightButtonDown( this->Interactor->GetControlKey(),
+ this->Interactor->GetShiftKey(),
+ x, y );
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::OnRightButtonUp()
+{
+ //cout << "void SVTK_InteractorStyle::OnRightButtonUp()" << endl;
+
+ int x, y;
+ this->Interactor->GetEventPosition( x, y );
+ this->OnRightButtonUp( this->Interactor->GetControlKey(),
+ this->Interactor->GetShiftKey(),
+ x, y );
+ /*
+ if( State == VTK_INTERACTOR_STYLE_CAMERA_NONE )
+ {
+ QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
+ event->pos(), event->globalPos(),
+ event->state() );
+ emit contextMenuRequested( &aEvent );
+ }
+ */
+}
+
+
//----------------------------------------------------------------------------
void
SVTK_InteractorStyle
onOperation(QPoint(x, y));
else if (ForcedState == VTK_INTERACTOR_STYLE_CAMERA_NONE)
onCursorMove(QPoint(x, y));
+
+ if( needsRedrawing() )
+ emit RenderWindowModified() ;
}
if (State == VTK_INTERACTOR_STYLE_CAMERA_FIT) {
// making fit rect opeation
int w, h;
- myInteractor->GetSize(w, h);
+ Interactor->GetSize(w, h);
int x1, y1, x2, y2;
x1 = rect.left();
y1 = h - rect.top() - 1;
if (myPoint == myOtherPoint) {
// process point selection
int w, h, x, y;
- myInteractor->GetSize(w, h);
+ Interactor->GetSize(w, h);
x = myPoint.x();
y = h - myPoint.y() - 1;
this->FindPokedRenderer(x, y);
- myInteractor->StartPickCallback();
+ Interactor->StartPickCallback();
- vtkPicker* aPicker = vtkPicker::SafeDownCast(myInteractor->GetPicker());
+ 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 = myInteractor->GetSelectionEvent();
+ SVTK_SelectionEvent aSelectionEvent = GetSelectionEvent();
aSelectionEvent.SelectionMode = aSelectionMode;
aSelectionEvent.IsRectangle = false;
if( aSActor )
- aSActor->Highlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true, true );
+ aSActor->Highlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
else
{
this->HighlightProp( NULL );
GetSelector()->ClearIObjects();
}
- myInteractor->EndPickCallback();
+ Interactor->EndPickCallback();
} else {
//processing rectangle selection
if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return;
- myInteractor->StartPickCallback();
+ Interactor->StartPickCallback();
if (!myShiftState) {
this->PropPicked = 0;
QRect rect(myPoint, myOtherPoint);
rect = rect.normalize();
int w, h;
- myInteractor->GetSize(w, h);
+ Interactor->GetSize(w, h);
int x1, y1, x2, y2;
x1 = rect.left();
y1 = h - rect.top() - 1;
x2 = rect.right();
y2 = h - rect.bottom() - 1;
- SVTK_SelectionEvent aSelectionEvent = myInteractor->GetSelectionEvent();
+ SVTK_SelectionEvent aSelectionEvent = GetSelectionEvent();
aSelectionEvent.SelectionMode = aSelectionMode;
aSelectionEvent.IsRectangle = true;
aSelectionEvent.LastX = x1;
switch (aSelectionMode) {
case NodeSelection: {
- if ( vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(myInteractor->GetPicker()) ) {
+ //if ( vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(Interactor->GetPicker()) ) {
vtkActorCollection* aListActors = this->CurrentRenderer->GetActors();
aListActors->InitTraversal();
while (vtkActor* aActor = aListActors->GetNextActor()) {
if (!aActor->GetVisibility())
continue;
if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor))
- aSActor->Highlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true, true );
+ aSActor->Highlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
}
- }
+ //}
break;
}
case CellSelection:
aListActors->InitTraversal();
while(vtkActor* aActor = aListActors->GetNextActor())
if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor))
- aSActor->Highlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true, true );
+ aSActor->Highlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
}
break;
case ActorSelection: // objects selection
aListActors->InitTraversal();
while(vtkActor* aActor = aListActors->GetNextActor())
if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor))
- aSActor->Highlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true, true );
+ aSActor->Highlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
} // end case 4
} //end switch
- myInteractor->EndPickCallback();
+ Interactor->EndPickCallback();
}
//myViewWindow->onSelectionChanged();
}
case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
{
int w, h, x, y;
- myInteractor->GetSize(w, h);
+ Interactor->GetSize(w, h);
x = myPoint.x();
y = h - myPoint.y() - 1;
Place(x, y);
::OnSelectionModeChanged()
{
- myPreSelectionActor->SetVisibility(false);
myElemId = myEdgeId = myNodeId = -1;
mySelectedActor = NULL;
}
Selection_Mode aSelectionMode = myViewWindow->SelectionMode();
int w, h, x, y;
- myInteractor->GetSize(w, h);
+ Interactor->GetSize(w, h);
x = mousePos.x(); y = h - mousePos.y() - 1;
this->FindPokedRenderer(x,y);
- myInteractor->StartPickCallback();
- myPreSelectionActor->SetVisibility(false);
+ Interactor->StartPickCallback();
- vtkPicker* aPicker = vtkPicker::SafeDownCast(myInteractor->GetPicker());
+ vtkPicker* aPicker = vtkPicker::SafeDownCast(Interactor->GetPicker());
SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
+
+ SVTK_SelectionEvent aSelectionEvent = GetSelectionEvent();
+ aSelectionEvent.X = x;
+ aSelectionEvent.Y = y;
+ aSelectionEvent.SelectionMode = aSelectionMode;
+
if( aSActor )
- aSActor->PreHighlight( this, -1 );
+ aSActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, false );
//cout << "onCursorMove : " << ( aSActor ? "1" : "0" ) << " ";
aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
//cout << ( aSActor ? "1" : "0" ) << endl;
if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
- int aVtkId = picker->GetCellId();
- if ( aVtkId >= 0 ) {
- int anObjId = aSActor->GetElemObjId(aVtkId);
- if ( aSActor && aSActor->hasIO() && IsValid( aSActor, aVtkId ) ) {
- bool anIsSameObjId = (mySelectedActor == aSActor && myElemId == anObjId);
- bool aResult = anIsSameObjId;
- if(!anIsSameObjId) {
- if(aSelectionMode != EdgeOfCellSelection) {
- aResult = CheckDimensionId(aSelectionMode,aSActor,anObjId);
- if(aResult){
- mySelectedActor = aSActor;
- myElemId = anObjId;
- if(MYDEBUG) INFOS(" CellId : "<<anObjId);
- //myInteractor->setCellData(anObjId,aSActor,myPreSelectionActor);
- }
- }
- }
- if(aSelectionMode == EdgeOfCellSelection){
- int anEdgeId = GetEdgeId(picker,aSActor,anObjId);
- bool anIsSameEdgeId = (myEdgeId != anEdgeId) && anIsSameObjId;
- aResult = anIsSameEdgeId;
- if(!anIsSameEdgeId) {
- aResult = (anEdgeId >= 0);
- if (aResult) {
- mySelectedActor = aSActor;
- myEdgeId = anEdgeId;
- myElemId = anObjId;
- if(MYDEBUG) INFOS(" CellId : "<<anObjId<<"; EdgeId : "<<anEdgeId);
- //myInteractor->setEdgeData(anObjId,aSActor,-anEdgeId-1,myPreSelectionActor);
- }
- }
- }
- if(aResult) {
- myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
- myPreSelectionActor->SetVisibility(true);
- }
- }
- }
+ if ( aSActor )
+ aSActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
}
else if (vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker)) {
- int aVtkId = picker->GetPointId();
- //cout << "vtkPointPicker" << endl;
- //cout << aSActor << endl;
- //cout << aVtkId << endl;
- if ( aVtkId >= 0 && IsValid( aSActor, aVtkId, true ) ) {
- if ( aSActor && aSActor->hasIO() ) {
- int anObjId = aSActor->GetNodeObjId(aVtkId);
- aSActor->PreHighlight( this, anObjId );
- /*
- bool anIsSameObjId = (mySelectedActor == aSActor && myNodeId == anObjId);
- if(!anIsSameObjId) {
- mySelectedActor = aSActor;
- myNodeId = anObjId;
- if(MYDEBUG) INFOS(" PointId : "<<anObjId);
- myInteractor->setPointData(anObjId,aSActor,myPreSelectionActor);
- aSActor->PreHighlight( this, anObjId );
- }
- myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
- myPreSelectionActor->SetVisibility(true);
- */
- }
- }
+ if ( aSActor )
+ aSActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
}
else if ( vtkPicker::SafeDownCast(aPicker) ) {
- if ( aSActor ) {
- if ( myPreViewActor != aSActor ) {
- if ( myPreViewActor != NULL ) {
- myPreViewActor->SetPreSelected( false );
- }
- myPreViewActor = aSActor;
-
- if ( aSActor->hasIO() ) {
- Handle( SALOME_InteractiveObject) IO = aSActor->getIO();
- if ( !GetSelector()->IsSelected(IO) ) {
- // Find All actors with same IO
- vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
- theActors->InitTraversal();
- while( vtkActor *ac = theActors->GetNextActor() ) {
- if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
- if ( anActor->hasIO() ) {
- Handle(SALOME_InteractiveObject) IOS = anActor->getIO();
- if(IO->isSame(IOS)) {
- anActor->SetPreSelected( true );
- }
- }
- }
- }
- }
- }
- }
- } else {
+ if( aSActor )
+ aSActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
+ /*
+ else {
myPreViewActor = NULL;
vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
theActors->InitTraversal();
}
}
}
+ */
}
- myInteractor->EndPickCallback();
- //myInteractor->Render();
+ Interactor->EndPickCallback();
+ //Interactor->Render();
myGUIWindow->update();
this->LastPos[0] = x;
#include <qobject.h>
#include <qcursor.h>
+#include <qevent.h>
#include <map>
#include "VTKViewer_Filter.h"
+#include "SVTK_SelectionEvent.h"
+
class VTKViewer_Trihedron;
class SALOME_Actor;
-class SVTK_Actor;
class SVTK_Viewer;
class SVTK_Selector;
class SVTK_ViewWindow;
-class SVTK_RenderWindowInteractor;
#define VTK_INTERACTOR_STYLE_CAMERA_NONE 0
#define VTK_INTERACTOR_STYLE_CAMERA_ROTATE 1
static SVTK_InteractorStyle *New();
vtkTypeMacro(SVTK_InteractorStyle, vtkInteractorStyle);
- virtual void SetInteractor(vtkRenderWindowInteractor *theInteractor);
void setViewWindow(SVTK_ViewWindow* theViewWindow);
void setGUIWindow(QWidget* theWindow);
virtual int GetState();
+ 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();
+ virtual void OnLeftButtonUp();
+ virtual void OnMiddleButtonDown();
+ virtual void OnMiddleButtonUp();
+ virtual void OnRightButtonDown();
+ virtual void OnRightButtonUp();
+
// Generic event bindings must be overridden in subclasses
void OnMouseMove (int ctrl, int shift, int x, int y);
void OnLeftButtonDown(int ctrl, int shift, int x, int y);
SALOME_Actor* myPreViewActor;
- SVTK_Actor* myPreSelectionActor;
SALOME_Actor* mySelectedActor;
int myElemId;
int myEdgeId;
void onCursorMove(QPoint mousePos);
void setCursor(const int operation);
+ signals:
+ void RenderWindowModified() ;
+ void contextMenuRequested( QContextMenuEvent *e );
+
protected:
QCursor myDefCursor;
QCursor myPanCursor;
bool myShiftState;
int ForcedState;
- SVTK_RenderWindowInteractor* myInteractor;
SVTK_ViewWindow* myViewWindow;
//merge with V2_2_0_VISU_improvements:VTKViewer_Trihedron* myTrihedron;
QWidget* myGUIWindow;
#include "SVTK_RenderWindowInteractor.h"
-#include "SVTK_InteractorStyle.h"
#include "SVTK_RenderWindow.h"
#include "SVTK_Selection.h"
#include <vtkPicker.h>
#include <vtkCellPicker.h>
#include <vtkPointPicker.h>
+#include <vtkInteractorStyle.h>
#include <vtkRendererCollection.h>
#include <vtkRenderWindow.h>
+#include <vtkCommand.h>
// QT Includes
#include <qkeycode.h>
return ;
}
-//----------------------------------------------------------------------------
-void
-SVTK_RenderWindowInteractor
-::SetInteractorStyle(vtkInteractorObserver *theInteractor)
-{
- myInteractorStyle = dynamic_cast<SVTK_InteractorStyle*>(theInteractor);
- vtkRenderWindowInteractor::SetInteractorStyle(theInteractor);
-}
-
-
-void
-SVTK_RenderWindowInteractor
-::SetSelectionMode(Selection_Mode theMode)
-{
- switch(theMode){
- case ActorSelection:
- this->SetPicker(myBasicPicker);
- break;
- case NodeSelection:
- this->SetPicker(myPointPicker);
- break;
- case CellSelection:
- case EdgeSelection:
- case FaceSelection:
- case VolumeSelection:
- case EdgeOfCellSelection:
- this->SetPicker(myCellPicker);
- break;
- }
-
- myInteractorStyle->OnSelectionModeChanged();
-}
-
-void
-SVTK_RenderWindowInteractor
-::SetSelectionProp(const double& theRed,
- const double& theGreen,
- const double& theBlue,
- const int& theWidth)
-{
- /*
- myCellActor->GetProperty()->SetColor(theRed, theGreen, theBlue);
- myCellActor->GetProperty()->SetLineWidth(theWidth);
-
- myPointActor->GetProperty()->SetColor(theRed, theGreen, theBlue);
- myPointActor->GetProperty()->SetPointSize(theWidth);
- */
-}
-
-void
-SVTK_RenderWindowInteractor
-::SetSelectionTolerance(const double& theTolNodes,
- const double& theTolItems)
-{
- myTolNodes = theTolNodes;
- myTolItems = theTolItems;
-
- myBasicPicker->SetTolerance(myTolItems);
- myCellPicker->SetTolerance(myTolItems);
- myPointPicker->SetTolerance(myTolNodes);
-
-}
-
// ==================================
void
SVTK_RenderWindowInteractor
return ;
}
- myInteractorStyle->OnTimer();
+ vtkInteractorStyle* aStyle = vtkInteractorStyle::SafeDownCast( InteractorStyle );
+ aStyle->OnTimer();
emit RenderWindowModified();
}
if( ! this->Enabled ) {
return ;
}
- myInteractorStyle->OnMouseMove(0, 0, event->x(), event->y()/*this->Size[1] - event->y() - 1*/) ;
- if (myInteractorStyle->needsRedrawing() )
- emit RenderWindowModified() ;
+
+ this->SetEventInformation( event->x(), event->y(),
+ ( event->state() & ControlButton ),
+ ( event->state() & ShiftButton ) );
+
+ if( this->HasObserver( vtkCommand::MouseMoveEvent ) )
+ this->InvokeEvent( vtkCommand::MouseMoveEvent, NULL );
}
void
if( ! this->Enabled ) {
return ;
}
- myInteractorStyle->OnLeftButtonDown((event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y());
+
+ this->SetEventInformation( event->x(), event->y(),
+ ( event->state() & ControlButton ),
+ ( event->state() & ShiftButton ) );
+
+ if( this->HasObserver( vtkCommand::LeftButtonPressEvent ) )
+ this->InvokeEvent( vtkCommand::LeftButtonPressEvent, NULL );
}
void
if( ! this->Enabled ) {
return ;
}
- this->SetEventInformationFlipY( event->x(), event->y(),
- ( event->state() & ControlButton ),
- ( event->state() & ShiftButton ) );
- myInteractorStyle->OnLeftButtonUp( (event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
+ this->SetEventInformation( event->x(), event->y(),
+ ( event->state() & ControlButton ),
+ ( event->state() & ShiftButton ) );
+
+ if( this->HasObserver( vtkCommand::LeftButtonReleaseEvent ) )
+ this->InvokeEvent( vtkCommand::LeftButtonReleaseEvent, NULL );
}
void
if( ! this->Enabled ) {
return ;
}
- myInteractorStyle->OnMiddleButtonDown((event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
+
+ this->SetEventInformation( event->x(), event->y(),
+ ( event->state() & ControlButton ),
+ ( event->state() & ShiftButton ) );
+
+ if( this->HasObserver( vtkCommand::MiddleButtonPressEvent ) )
+ this->InvokeEvent( vtkCommand::MiddleButtonPressEvent, NULL );
}
void
if( ! this->Enabled ) {
return ;
}
- myInteractorStyle->OnMiddleButtonUp( (event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
+
+ this->SetEventInformation( event->x(), event->y(),
+ ( event->state() & ControlButton ),
+ ( event->state() & ShiftButton ) );
+
+ if( this->HasObserver( vtkCommand::MiddleButtonReleaseEvent ) )
+ this->InvokeEvent( vtkCommand::MiddleButtonReleaseEvent, NULL );
}
void
if( ! this->Enabled ) {
return ;
}
- myInteractorStyle->OnRightButtonDown( (event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
+
+ this->SetEventInformation( event->x(), event->y(),
+ ( event->state() & ControlButton ),
+ ( event->state() & ShiftButton ) );
+
+ if( this->HasObserver( vtkCommand::RightButtonPressEvent ) )
+ this->InvokeEvent( vtkCommand::RightButtonPressEvent, NULL );
}
void
if( ! this->Enabled ) {
return ;
}
- myInteractorStyle->OnRightButtonUp( (event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
- if(myInteractorStyle->GetState() == VTK_INTERACTOR_STYLE_CAMERA_NONE && !( event->state() & KeyButtonMask )){
+ this->SetEventInformation( event->x(), event->y(),
+ ( event->state() & ControlButton ),
+ ( event->state() & ShiftButton ) );
+
+ if( this->HasObserver( vtkCommand::RightButtonReleaseEvent ) )
+ this->InvokeEvent( vtkCommand::RightButtonReleaseEvent, NULL );
+
+ if(/*myInteractorStyle->GetState() == VTK_INTERACTOR_STYLE_CAMERA_NONE && */!( event->state() & KeyButtonMask )){
QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
event->pos(), event->globalPos(),
event->state() );
TSetFunction<SALOME_Actor,const char*,QString>
(&SALOME_Actor::setName,theName.latin1()));
}
-
-SVTK_SelectionEvent
-SVTK_RenderWindowInteractor
-::GetSelectionEvent()
-{
- SVTK_SelectionEvent aSelectionEvent;
-
- int x, y;
- this->GetEventPosition( x, y );
-
- aSelectionEvent.X = x;
- aSelectionEvent.Y = y;
- aSelectionEvent.IsCtrl = this->GetControlKey();
- aSelectionEvent.IsShift = this->GetShiftKey();
-
- return aSelectionEvent;
-}
#define SVTK_RenderWindowInteractor_h
#include "SVTK.h"
-#include "SVTK_SelectionEvent.h"
+#include "SVTK_Selection.h"
#include "SALOME_InteractiveObject.hxx"
class SVTK_ViewWindow;
class SVTK_RenderWindow;
-class SVTK_InteractorStyle;
// ------------------------------------------------------------
// :TRICKY: Fri Apr 21 22:19:27 2000 Pagey
// want to have mouse interaction.
virtual void Initialize();
- virtual void SetInteractorStyle(vtkInteractorObserver *);
- SVTK_InteractorStyle* GetSInteractorStyle(){ return myInteractorStyle;}
-
// Description:
// This will start up the X event loop and never return. If you
// call this method it will loop processing X events until the
bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject);
bool isVisible( const Handle(SALOME_InteractiveObject)& IObject);
void rename(const Handle(SALOME_InteractiveObject)& IObject, QString newName);
-
+ /*
void SetSelectionMode(Selection_Mode mode);
void SetSelectionProp(const double& theRed = 1,
const double& theGreen = 1,
const int& theWidth = 5);
void SetSelectionTolerance(const double& theTolNodes = 0.025,
const double& theTolCell = 0.001);
-
+ */
// Displaymode management
int GetDisplayMode();
void SetDisplayMode(int);
vtkRenderer* GetRenderer();
- SVTK_SelectionEvent GetSelectionEvent();
-
protected:
SVTK_RenderWindowInteractor();
~SVTK_RenderWindowInteractor();
- SVTK_InteractorStyle* myInteractorStyle;
-
// Timer used during various mouse events to figure
// out mouse movements.
QTimer *mTimer ;
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkCamera.h>
+#include <vtkPointPicker.h>
+#include <vtkCellPicker.h>
#include "QtxAction.h"
#include "VTKViewer_Transform.h"
#include "VTKViewer_Utilities.h"
+#include "VTKViewer_CellRectPicker.h"
#include "SVTK_Trihedron.h"
#include "SVTK_CubeAxesActor2D.h"
myRWInteractor->SetRenderWindow( myRenderWindow->getRenderWindow() );
//myRWInteractor->setViewWindow( this );
- SVTK_InteractorStyle* RWS = SVTK_InteractorStyle::New();
- RWS->setGUIWindow( myRenderWindow );
- RWS->setViewWindow( this );
+ myInteractorStyle = SVTK_InteractorStyle::New();
+ myInteractorStyle->setGUIWindow( myRenderWindow );
+ myInteractorStyle->setViewWindow( this );
- myRWInteractor->SetInteractorStyle( RWS );
+ myRWInteractor->SetInteractorStyle( myInteractorStyle );
myRWInteractor->Initialize();
- //merge with V2_2_0_VISU_improvements:RWS->setTriedron( myTrihedron );
- RWS->FindPokedRenderer( 0, 0 );
+ //merge with V2_2_0_VISU_improvements:myInteractorStyle->setTriedron( myTrihedron );
+ myInteractorStyle->FindPokedRenderer( 0, 0 );
SetSelectionMode(ActorSelection);
connect( myRenderWindow, SIGNAL(MouseMove( QMouseEvent* )),
this, SLOT(onMouseMoving( QMouseEvent* )) );
+ connect( myInteractorStyle, SIGNAL(RenderWindowModified()),
+ myRenderWindow, SLOT(update()) );
connect( myRWInteractor, SIGNAL(RenderWindowModified()),
myRenderWindow, SLOT(update()) );
connect( myRWInteractor, SIGNAL(contextMenuRequested( QContextMenuEvent * )),
SVTK_ViewWindow
::activateZoom()
{
- myRWInteractor->GetSInteractorStyle()->startZoom();
+ myInteractorStyle->startZoom();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::activatePanning()
{
- myRWInteractor->GetSInteractorStyle()->startPan();
+ myInteractorStyle->startPan();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::activateRotation()
{
- myRWInteractor->GetSInteractorStyle()->startRotate();
+ myInteractorStyle->startRotate();
}
//----------------------------------------------------------------------------
::activateGlobalPanning()
{
if(myTrihedron->GetVisibleActorCount(myRenderer))
- myRWInteractor->GetSInteractorStyle()->startGlobalPan();
+ myInteractorStyle->startGlobalPan();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::activateWindowFit()
{
- myRWInteractor->GetSInteractorStyle()->startFitArea();
+ myInteractorStyle->startFitArea();
}
//----------------------------------------------------------------------------
{
mySelector->SetSelectionMode(theMode);
- myRWInteractor->SetSelectionMode(theMode);
+ //myRWInteractor->SetSelectionMode(theMode);
}
//----------------------------------------------------------------
SVTK_ViewWindow
::onPanLeft()
{
- myRWInteractor->GetSInteractorStyle()->IncrementalPan( -INCREMENT_FOR_OP, 0 );
+ myInteractorStyle->IncrementalPan( -INCREMENT_FOR_OP, 0 );
}
//=======================================================================
SVTK_ViewWindow
::onPanRight()
{
- myRWInteractor->GetSInteractorStyle()->IncrementalPan( INCREMENT_FOR_OP, 0 );
+ myInteractorStyle->IncrementalPan( INCREMENT_FOR_OP, 0 );
}
//=======================================================================
SVTK_ViewWindow
::onPanUp()
{
- myRWInteractor->GetSInteractorStyle()->IncrementalPan( 0, INCREMENT_FOR_OP );
+ myInteractorStyle->IncrementalPan( 0, INCREMENT_FOR_OP );
}
//=======================================================================
SVTK_ViewWindow
::onPanDown()
{
- myRWInteractor->GetSInteractorStyle()->IncrementalPan( 0, -INCREMENT_FOR_OP );
+ myInteractorStyle->IncrementalPan( 0, -INCREMENT_FOR_OP );
}
//=======================================================================
SVTK_ViewWindow
::onZoomIn()
{
- myRWInteractor->GetSInteractorStyle()->IncrementalZoom( INCREMENT_FOR_OP );
+ myInteractorStyle->IncrementalZoom( INCREMENT_FOR_OP );
}
//=======================================================================
SVTK_ViewWindow
::onZoomOut()
{
- myRWInteractor->GetSInteractorStyle()->IncrementalZoom( -INCREMENT_FOR_OP );
+ myInteractorStyle->IncrementalZoom( -INCREMENT_FOR_OP );
}
//=======================================================================
SVTK_ViewWindow
::onRotateLeft()
{
- myRWInteractor->GetSInteractorStyle()->IncrementalRotate( -INCREMENT_FOR_OP, 0 );
+ myInteractorStyle->IncrementalRotate( -INCREMENT_FOR_OP, 0 );
}
//=======================================================================
SVTK_ViewWindow
::onRotateRight()
{
- myRWInteractor->GetSInteractorStyle()->IncrementalRotate( INCREMENT_FOR_OP, 0 );
+ myInteractorStyle->IncrementalRotate( INCREMENT_FOR_OP, 0 );
}
//=======================================================================
SVTK_ViewWindow
::onRotateUp()
{
- myRWInteractor->GetSInteractorStyle()->IncrementalRotate( 0, -INCREMENT_FOR_OP );
+ myInteractorStyle->IncrementalRotate( 0, -INCREMENT_FOR_OP );
}
//=======================================================================
SVTK_ViewWindow
::onRotateDown()
{
- myRWInteractor->GetSInteractorStyle()->IncrementalRotate( 0, INCREMENT_FOR_OP );
+ myInteractorStyle->IncrementalRotate( 0, INCREMENT_FOR_OP );
}
//----------------------------------------------------------------------------
QPixmap px = QPixmap::grabWindow( myRenderWindow->winId() );
return px.convertToImage();
}
+
+void
+SVTK_ViewWindow
+::SetSelectionProp(const double& theRed,
+ const double& theGreen,
+ const double& theBlue,
+ const int& theWidth)
+{
+ vtkActorCollection* anActors = getRenderer()->GetActors();
+ anActors->InitTraversal();
+ while( vtkActor* anActor = anActors->GetNextActor() )
+ {
+ if( SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast( anActor ) )
+ {
+ aSActor->getPointProperty()->SetColor( theRed, theGreen, theBlue );
+ aSActor->getPointProperty()->SetLineWidth( theWidth );
+
+ aSActor->getCellProperty()->SetColor( theRed, theGreen, theBlue );
+ aSActor->getCellProperty()->SetLineWidth( theWidth );
+
+ aSActor->getEdgeProperty()->SetColor( theRed, theGreen, theBlue );
+ aSActor->getEdgeProperty()->SetLineWidth( theWidth );
+ }
+ }
+}
+
+void
+SVTK_ViewWindow
+::SetSelectionTolerance(const double& theTolNodes,
+ const double& theTolItems)
+{
+ vtkActorCollection* anActors = getRenderer()->GetActors();
+ anActors->InitTraversal();
+ while( vtkActor* anActor = anActors->GetNextActor() )
+ {
+ if( SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast( anActor ) )
+ {
+ aSActor->getPointPicker()->SetTolerance( theTolNodes );
+ aSActor->getCellPicker()->SetTolerance( theTolItems );
+ aSActor->getCellRectPicker()->SetTolerance( theTolItems );
+ }
+ }
+}
class SVTK_RenderWindow;
class SVTK_InteractorStyle;
class SVTK_RenderWindowInteractor;
+class SVTK_InteractorStyle;
class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
{
SVTK_Selector* GetSelector() {return mySelector;}
SVTK_RenderWindow* getRenderWindow() {return myRenderWindow;}
SVTK_RenderWindowInteractor* getRWInteractor() {return myRWInteractor;}
+ SVTK_InteractorStyle* getInteractorStyle(){ return myInteractorStyle;}
Selection_Mode SelectionMode() const;
void SetSelectionMode(Selection_Mode theMode);
VTKViewer_Trihedron* GetTrihedron() {return this->myTrihedron;};
SVTK_CubeAxesActor2D* GetCubeAxes() {return this->myCubeAxes;};
+ void SetSelectionProp(const double& theRed = 1,
+ const double& theGreen = 1,
+ const double& theBlue = 0,
+ const int& theWidth = 5);
+ void SetSelectionTolerance(const double& theTolNodes = 0.025,
+ const double& theTolCell = 0.001);
+
public slots:
void onSelectionChanged();
SVTK_RenderWindow* myRenderWindow;
SVTK_RenderWindowInteractor* myRWInteractor;
+ SVTK_InteractorStyle* myInteractorStyle;
VTKViewer_Transform* myTransform;
VTKViewer_Trihedron* myTrihedron;