1 // SALOME VTKViewer : build VTK viewer into Salome desktop
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : VTKViewer_InteractorStyle.cxx
25 // Author : Christophe ATTANASIO
28 #include "VTKViewer_InteractorStyle.h"
30 #include "VTKViewer_Actor.h"
31 #include "VTKViewer_Utilities.h"
32 #include "VTKViewer_Trihedron.h"
33 #include "VTKViewer_RectPicker.h"
34 #include "VTKViewer_ViewWindow.h"
35 #include "VTKViewer_RenderWindow.h"
36 #include "VTKViewer_CellRectPicker.h"
37 #include "VTKViewer_RenderWindowInteractor.h"
39 //#include "SALOME_Actor.h"
41 #include <vtkObjectFactory.h>
43 #include <vtkCommand.h>
44 #include <vtkCamera.h>
45 #include <vtkRenderer.h>
46 #include <vtkPicker.h>
47 #include <vtkPointPicker.h>
48 #include <vtkCellPicker.h>
50 #include <vtkMapper.h>
51 #include <vtkDataSet.h>
52 #include <vtkSmartPointer.h>
54 #include <qapplication.h>
55 //VRV: porting on Qt 3.0.5
56 #if QT_VERSION >= 0x030005
59 //VRV: porting on Qt 3.0.5
62 //#include "utilities.h"
68 static int MYDEBUG = 0;
70 static int MYDEBUG = 0;
74 static int GetEdgeId(vtkPicker *thePicker, SALOME_Actor *theActor, int theObjId){
76 if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) {
77 float aPickPosition[3];
78 thePicker->GetPickPosition(aPickPosition);
79 float aMinDist = 1000000.0, aDist = 0;
80 for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
81 if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){
82 int subId; float pcoords[3], closestPoint[3], weights[3];
83 aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
84 if (aDist < aMinDist) {
94 //----------------------------------------------------------------------------
95 vtkStandardNewMacro(VTKViewer_InteractorStyle);
96 //----------------------------------------------------------------------------
98 VTKViewer_InteractorStyle::VTKViewer_InteractorStyle()
101 this->MotionFactor = 10.0;
102 this->State = VTK_INTERACTOR_STYLE_CAMERA_NONE;
103 this->RadianToDegree = 180.0 / vtkMath::Pi();
104 this->ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE;
107 myPreSelectionActor = VTKViewer_Actor::New();
108 myPreSelectionActor->GetProperty()->SetColor(0,1,1);
109 myPreSelectionActor->GetProperty()->SetLineWidth(5);
110 myPreSelectionActor->GetProperty()->SetPointSize(5);
112 OnSelectionModeChanged();
115 //----------------------------------------------------------------------------
116 VTKViewer_InteractorStyle::~VTKViewer_InteractorStyle()
118 // if(MYDEBUG) INFOS("VTKViewer_InteractorStyle::~VTKViewer_InteractorStyle()");
119 m_ViewWnd->RemoveActor(myPreSelectionActor);
122 //----------------------------------------------------------------------------
123 void VTKViewer_InteractorStyle::setPreselectionProp(const double& theRed, const double& theGreen,
124 const double& theBlue, const int& theWidth)
126 if ( myPreSelectionActor->GetProperty() == 0 )
128 myPreSelectionActor->GetProperty()->SetColor(theRed, theGreen, theBlue);
129 myPreSelectionActor->GetProperty()->SetLineWidth(theWidth);
130 myPreSelectionActor->GetProperty()->SetPointSize(theWidth);
133 //----------------------------------------------------------------------------
134 void VTKViewer_InteractorStyle::SetInteractor(vtkRenderWindowInteractor *theInteractor){
135 m_Interactor = dynamic_cast<VTKViewer_RenderWindowInteractor*>(theInteractor);
136 Superclass::SetInteractor(theInteractor);
139 //----------------------------------------------------------------------------
140 void VTKViewer_InteractorStyle::setViewWnd(VTKViewer_ViewWindow* theViewWnd ){
141 m_ViewWnd = theViewWnd;
142 m_ViewWnd->AddActor(myPreSelectionActor);
143 myPreSelectionActor->Delete();
146 //----------------------------------------------------------------------------
147 void VTKViewer_InteractorStyle::setGUIWindow(QWidget* theWindow){
148 myGUIWindow = theWindow;
151 //----------------------------------------------------------------------------
152 void VTKViewer_InteractorStyle::setTriedron(VTKViewer_Trihedron* theTrihedron){
153 m_Trihedron = theTrihedron;
156 //----------------------------------------------------------------------------
157 void VTKViewer_InteractorStyle::RotateXY(int dx, int dy)
163 if (this->CurrentRenderer == NULL)
168 int *size = this->CurrentRenderer->GetRenderWindow()->GetSize();
169 this->DeltaElevation = -20.0 / size[1];
170 this->DeltaAzimuth = -20.0 / size[0];
172 rxf = (double)dx * this->DeltaAzimuth * this->MotionFactor;
173 ryf = (double)dy * this->DeltaElevation * this->MotionFactor;
175 cam = this->CurrentRenderer->GetActiveCamera();
178 cam->OrthogonalizeViewUp();
179 ::ResetCameraClippingRange(this->CurrentRenderer);
180 //this->Interactor->Render();
181 myGUIWindow->update();
184 //----------------------------------------------------------------------------
185 void VTKViewer_InteractorStyle::PanXY(int x, int y, int oldX, int oldY)
187 TranslateView(x, y, oldX, oldY);
188 //this->Interactor->Render();
189 myGUIWindow->update();
193 //----------------------------------------------------------------------------
194 void VTKViewer_InteractorStyle::DollyXY(int dx, int dy)
196 if (this->CurrentRenderer == NULL) return;
198 double dxf = this->MotionFactor * (double)(dx) / (double)(this->CurrentRenderer->GetCenter()[1]);
199 double dyf = this->MotionFactor * (double)(dy) / (double)(this->CurrentRenderer->GetCenter()[1]);
201 double zoomFactor = pow((double)1.1, dxf + dyf);
203 vtkCamera *aCam = this->CurrentRenderer->GetActiveCamera();
204 if (aCam->GetParallelProjection())
205 aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor);
207 aCam->Dolly(zoomFactor);
208 ::ResetCameraClippingRange(this->CurrentRenderer);
211 //this->Interactor->Render();
212 myGUIWindow->update();
215 //----------------------------------------------------------------------------
216 void VTKViewer_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY)
220 if (this->CurrentRenderer == NULL)
225 double newAngle = atan2((double)(y - this->CurrentRenderer->GetCenter()[1]),
226 (double)(x - this->CurrentRenderer->GetCenter()[0]));
227 double oldAngle = atan2((double)(oldY -this->CurrentRenderer->GetCenter()[1]),
228 (double)(oldX - this->CurrentRenderer->GetCenter()[0]));
230 newAngle *= this->RadianToDegree;
231 oldAngle *= this->RadianToDegree;
233 cam = this->CurrentRenderer->GetActiveCamera();
234 cam->Roll(newAngle - oldAngle);
235 cam->OrthogonalizeViewUp();
237 //this->Interactor->Render();
238 myGUIWindow->update();
242 //----------------------------------------------------------------------------
243 void VTKViewer_InteractorStyle::OnMouseMove(int vtkNotUsed(ctrl),
247 myShiftState = shift;
248 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
249 onOperation(QPoint(x, y));
250 else if (ForcedState == VTK_INTERACTOR_STYLE_CAMERA_NONE)
251 onCursorMove(QPoint(x, y));
255 //----------------------------------------------------------------------------
256 void VTKViewer_InteractorStyle::OnLeftButtonDown(int ctrl, int shift,
259 if (this->HasObserver(vtkCommand::LeftButtonPressEvent)) {
260 this->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL);
263 this->FindPokedRenderer(x, y);
264 if (this->CurrentRenderer == NULL) {
267 myShiftState = shift;
268 // finishing current viewer operation
269 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
271 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
273 myOtherPoint = myPoint = QPoint(x, y);
274 if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
275 startOperation(ForcedState);
278 startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
280 startOperation(VTK_INTERACTOR_STYLE_CAMERA_SELECT);
286 //----------------------------------------------------------------------------
287 void VTKViewer_InteractorStyle::OnLeftButtonUp(int vtkNotUsed(ctrl),
292 myShiftState = shift;
293 // finishing current viewer operation
294 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
296 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
301 //----------------------------------------------------------------------------
302 void VTKViewer_InteractorStyle::OnMiddleButtonDown(int ctrl,
306 if (this->HasObserver(vtkCommand::MiddleButtonPressEvent))
308 this->InvokeEvent(vtkCommand::MiddleButtonPressEvent,NULL);
311 this->FindPokedRenderer(x, y);
312 if (this->CurrentRenderer == NULL)
316 myShiftState = shift;
317 // finishing current viewer operation
318 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
320 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
322 myOtherPoint = myPoint = QPoint(x, y);
323 if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
324 startOperation(ForcedState);
328 startOperation(VTK_INTERACTOR_STYLE_CAMERA_PAN);
333 //----------------------------------------------------------------------------
334 void VTKViewer_InteractorStyle::OnMiddleButtonUp(int vtkNotUsed(ctrl),
339 myShiftState = shift;
340 // finishing current viewer operation
341 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
343 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
348 //----------------------------------------------------------------------------
349 void VTKViewer_InteractorStyle::OnRightButtonDown(int ctrl,
353 if (this->HasObserver(vtkCommand::RightButtonPressEvent))
355 this->InvokeEvent(vtkCommand::RightButtonPressEvent,NULL);
358 this->FindPokedRenderer(x, y);
359 if (this->CurrentRenderer == NULL)
363 myShiftState = shift;
364 // finishing current viewer operation
365 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
367 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
369 myOtherPoint = myPoint = QPoint(x, y);
370 if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
371 startOperation(ForcedState);
375 startOperation(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
379 //----------------------------------------------------------------------------
380 void VTKViewer_InteractorStyle::OnRightButtonUp(int vtkNotUsed(ctrl),
385 myShiftState = shift;
386 // finishing current viewer operation
387 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
389 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
393 //----------------------------------------------------------------------------
395 const char* imageZoomCursor[] = {
400 "................................",
401 "................................",
402 ".#######........................",
403 "..aaaaaaa.......................",
404 "................................",
405 ".............#####..............",
406 "...........##.aaaa##............",
407 "..........#.aa.....a#...........",
408 ".........#.a.........#..........",
409 ".........#a..........#a.........",
410 "........#.a...........#.........",
411 "........#a............#a........",
412 "........#a............#a........",
413 "........#a............#a........",
414 "........#a............#a........",
415 ".........#...........#.a........",
416 ".........#a..........#a.........",
417 ".........##.........#.a.........",
418 "........#####.....##.a..........",
419 ".......###aaa#####.aa...........",
420 "......###aa...aaaaa.......#.....",
421 ".....###aa................#a....",
422 "....###aa.................#a....",
423 "...###aa...............#######..",
424 "....#aa.................aa#aaaa.",
425 ".....a....................#a....",
426 "..........................#a....",
427 "...........................a....",
428 "................................",
429 "................................",
430 "................................",
431 "................................"};
433 const char* imageRotateCursor[] = {
438 "................................",
439 "................................",
440 "................................",
441 "................................",
442 "........#.......................",
443 ".......#.a......................",
444 "......#######...................",
445 ".......#aaaaa#####..............",
446 "........#..##.a#aa##........##..",
447 ".........a#.aa..#..a#.....##.aa.",
448 ".........#.a.....#...#..##.aa...",
449 ".........#a.......#..###.aa.....",
450 "........#.a.......#a..#aa.......",
451 "........#a.........#..#a........",
452 "........#a.........#a.#a........",
453 "........#a.........#a.#a........",
454 "........#a.........#a.#a........",
455 ".........#.........#a#.a........",
456 "........##a........#a#a.........",
457 "......##.a#.......#.#.a.........",
458 "....##.aa..##.....##.a..........",
459 "..##.aa.....a#####.aa...........",
460 "...aa.........aaa#a.............",
461 "................#.a.............",
462 "...............#.a..............",
463 "..............#.a...............",
464 "...............a................",
465 "................................",
466 "................................",
467 "................................",
468 "................................",
469 "................................"};
472 //----------------------------------------------------------------------------
473 // loads cursors for viewer operations - zoom, pan, etc...
474 void VTKViewer_InteractorStyle::loadCursors()
476 myDefCursor = QCursor(ArrowCursor);
477 myHandCursor = QCursor(PointingHandCursor);
478 myPanCursor = QCursor(SizeAllCursor);
479 myZoomCursor = QCursor(QPixmap(imageZoomCursor));
480 myRotateCursor = QCursor(QPixmap(imageRotateCursor));
481 mySpinCursor = QCursor(QPixmap(imageRotateCursor)); // temporarly !!!!!!
482 myGlobalPanCursor = QCursor(CrossCursor);
483 myCursorState = false;
487 //----------------------------------------------------------------------------
488 // event filter - controls mouse and keyboard events during viewer operations
489 bool VTKViewer_InteractorStyle::eventFilter(QObject* object, QEvent* event)
491 if (!myGUIWindow) return false;
492 if ( (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::KeyPress) && object != myGUIWindow)
494 qApp->removeEventFilter(this);
495 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
497 return QObject::eventFilter(object, event);
501 //----------------------------------------------------------------------------
502 // starts Zoom operation (e.g. through menu command)
503 void VTKViewer_InteractorStyle::startZoom()
505 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
508 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
510 setCursor(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
511 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ZOOM;
512 qApp->installEventFilter(this);
516 //----------------------------------------------------------------------------
517 // starts Pan operation (e.g. through menu command)
518 void VTKViewer_InteractorStyle::startPan()
520 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
523 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
525 setCursor(VTK_INTERACTOR_STYLE_CAMERA_PAN);
526 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_PAN;
527 qApp->installEventFilter(this);
530 //----------------------------------------------------------------------------
531 // starts Rotate operation (e.g. through menu command)
532 void VTKViewer_InteractorStyle::startRotate()
534 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
537 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
539 setCursor(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
540 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ROTATE;
541 qApp->installEventFilter(this);
545 //----------------------------------------------------------------------------
546 // starts Spin operation (e.g. through menu command)
547 void VTKViewer_InteractorStyle::startSpin()
549 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
552 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
554 setCursor(VTK_INTERACTOR_STYLE_CAMERA_SPIN);
555 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_SPIN;
556 qApp->installEventFilter(this);
561 //----------------------------------------------------------------------------
562 // starts Fit Area operation (e.g. through menu command)
563 void VTKViewer_InteractorStyle::startFitArea()
565 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
568 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
570 setCursor(VTK_INTERACTOR_STYLE_CAMERA_FIT);
571 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_FIT;
572 qApp->installEventFilter(this);
576 //----------------------------------------------------------------------------
577 void VTKViewer_InteractorStyle::ViewFitAll() {
578 int aTriedronWasVisible = false;
580 aTriedronWasVisible = m_Trihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
581 if(aTriedronWasVisible) m_Trihedron->VisibilityOff();
584 if(m_Trihedron->GetVisibleActorCount(CurrentRenderer)){
585 m_Trihedron->VisibilityOff();
586 ::ResetCamera(CurrentRenderer);
588 m_Trihedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn);
589 ::ResetCamera(CurrentRenderer,true);
591 if(aTriedronWasVisible) m_Trihedron->VisibilityOn();
592 else m_Trihedron->VisibilityOff();
593 ::ResetCameraClippingRange(CurrentRenderer);
597 //----------------------------------------------------------------------------
598 // starts Global Panning operation (e.g. through menu command)
599 void VTKViewer_InteractorStyle::startGlobalPan()
601 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
604 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
606 setCursor(VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN);
607 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN;
609 // store current zoom scale
610 vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
611 myScale = cam->GetParallelScale();
615 if (myGUIWindow) myGUIWindow->update();
617 qApp->installEventFilter(this);
621 //----------------------------------------------------------------------------
622 // returns TRUE if needs redrawing
623 bool VTKViewer_InteractorStyle::needsRedrawing()
625 return State == VTK_INTERACTOR_STYLE_CAMERA_ZOOM ||
626 State == VTK_INTERACTOR_STYLE_CAMERA_PAN ||
627 State == VTK_INTERACTOR_STYLE_CAMERA_ROTATE ||
628 State == VTK_INTERACTOR_STYLE_CAMERA_SPIN ||
629 State == VTK_INTERACTOR_STYLE_CAMERA_NONE;
633 //----------------------------------------------------------------------------
634 // fits viewer contents to rect
635 void VTKViewer_InteractorStyle::fitRect(const int left,
640 if (this->CurrentRenderer == NULL) return;
643 int x = (left + right)/2;
644 int y = (top + bottom)/2;
645 int *aSize = this->CurrentRenderer->GetRenderWindow()->GetSize();
646 int oldX = aSize[0]/2;
647 int oldY = aSize[1]/2;
648 TranslateView(oldX, oldY, x, y);
651 double dxf = (double)(aSize[0]) / (double)(abs(right - left));
652 double dyf = (double)(aSize[1]) / (double)(abs(bottom - top));
653 double zoomFactor = (dxf + dyf)/2 ;
655 vtkCamera *aCam = this->CurrentRenderer->GetActiveCamera();
656 if(aCam->GetParallelProjection())
657 aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor);
659 aCam->Dolly(zoomFactor);
660 ::ResetCameraClippingRange(this->CurrentRenderer);
663 myGUIWindow->update();
667 //----------------------------------------------------------------------------
668 // starts viewer operation (!internal usage!)
669 void VTKViewer_InteractorStyle::startOperation(int operation)
673 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
674 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
675 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
676 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
677 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
678 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
679 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
680 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
681 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
683 if (State != VTK_INTERACTOR_STYLE_CAMERA_SELECT)
684 setCursor(operation);
687 case VTK_INTERACTOR_STYLE_CAMERA_NONE:
689 setCursor(VTK_INTERACTOR_STYLE_CAMERA_NONE);
690 State = ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE;
696 //----------------------------------------------------------------------------
697 // sets proper cursor for window when viewer operation is activated
698 void VTKViewer_InteractorStyle::setCursor(const int operation)
700 if (!myGUIWindow) return;
703 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
704 myGUIWindow->setCursor(myZoomCursor);
705 myCursorState = true;
707 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
708 myGUIWindow->setCursor(myPanCursor);
709 myCursorState = true;
711 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
712 myGUIWindow->setCursor(myRotateCursor);
713 myCursorState = true;
715 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
716 myGUIWindow->setCursor(mySpinCursor);
717 myCursorState = true;
719 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
720 myGUIWindow->setCursor(myGlobalPanCursor);
721 myCursorState = true;
723 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
724 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
725 myGUIWindow->setCursor(myHandCursor);
726 myCursorState = true;
728 case VTK_INTERACTOR_STYLE_CAMERA_NONE:
730 myGUIWindow->setCursor(myDefCursor);
731 myCursorState = false;
737 //----------------------------------------------------------------------------
738 // called when viewer operation started (!put necessary initialization here!)
739 void VTKViewer_InteractorStyle::onStartOperation()
741 if (!myGUIWindow) return;
742 // VSV: LOD actor activisation
743 // this->Interactor->GetRenderWindow()->SetDesiredUpdateRate(this->Interactor->GetDesiredUpdateRate());
745 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
746 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
748 QPainter p(myGUIWindow);
749 p.setPen(Qt::lightGray);
750 p.setRasterOp(Qt::XorROP);
751 p.drawRect(QRect(myPoint, myOtherPoint));
754 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
755 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
756 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
757 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
758 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
764 //----------------------------------------------------------------------------
765 // called when viewer operation finished (!put necessary post-processing here!)
766 void VTKViewer_InteractorStyle::onFinishOperation()
768 if (!myGUIWindow) return;
771 // SUIT_Study* aActiveStudy = SUIT_Application::getDesktop()->getActiveStudy();
772 // SALOME_Selection* aSel = SALOME_Selection::Selection( aActiveStudy->getSelection() );
774 // VSV: LOD actor activisation
775 // rwi->GetRenderWindow()->SetDesiredUpdateRate(rwi->GetStillUpdateRate());
777 // Selection_Mode aSelectionMode = aSel->SelectionMode();
778 // bool aSelActiveCompOnly = aSel->IsSelectActiveCompOnly();
781 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
782 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
784 QPainter p(myGUIWindow);
785 p.setPen(Qt::lightGray);
786 p.setRasterOp(Qt::XorROP);
787 QRect rect(myPoint, myOtherPoint);
789 rect = rect.normalize();
790 if (State == VTK_INTERACTOR_STYLE_CAMERA_FIT) {
791 // making fit rect opeation
793 m_Interactor->GetSize(w, h);
796 y1 = h - rect.top() - 1;
798 y2 = h - rect.bottom() - 1;
799 fitRect(x1, y1, x2, y2);
802 if (myPoint == myOtherPoint) {
803 // process point selection
805 m_Interactor->GetSize(w, h);
807 y = h - myPoint.y() - 1;
809 this->FindPokedRenderer(x, y);
810 m_Interactor->StartPickCallback();
812 vtkPicker* aPicker = vtkPicker::SafeDownCast(m_Interactor->GetPicker());
813 aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
815 SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
817 if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
818 int aVtkId = picker->GetCellId();
819 if ( aVtkId >= 0 && SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) {
820 int anObjId = SActor->GetElemObjId(aVtkId);
822 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
823 if(aSelectionMode != EdgeOfCellSelection) {
824 if(CheckDimensionId(aSelectionMode,SActor,anObjId)){
825 if(MYDEBUG) INFOS(" CellId : "<<anObjId);
826 if (IsSelected(IO,aSel)) {
827 // This IO is already in the selection
828 aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
831 this->HighlightProp( NULL );
832 aSel->ClearIObjects();
834 aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
835 aSel->AddIObject( IO, false );
840 this->HighlightProp( NULL );
841 aSel->ClearIObjects();
843 int anEdgeId = GetEdgeId(picker,SActor,anObjId);
845 if(MYDEBUG) INFOS(" CellId : "<<anObjId<<"; EdgeId : "<<anEdgeId);
846 aSel->AddOrRemoveIndex( IO, anObjId, true, false);
847 aSel->AddOrRemoveIndex( IO, -anEdgeId-1, true, true );
848 aSel->AddIObject( IO, false );
853 this->HighlightProp( NULL );
854 aSel->ClearIObjects();
856 } else if ( vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker) ) {
857 int aVtkId = picker->GetPointId();
858 if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) {
859 if ( SActor && SActor->hasIO() ) {
860 int anObjId = SActor->GetNodeObjId(aVtkId);
862 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
863 if(IsSelected(IO,aSel)) {
864 // This IO is already in the selection
865 aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
868 this->HighlightProp( NULL );
869 aSel->ClearIObjects();
871 if(MYDEBUG) INFOS(" PointId : "<<anObjId);
872 aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
873 aSel->AddIObject( IO, false );
878 this->HighlightProp( NULL );
879 aSel->ClearIObjects();
882 if ( SActor && SActor->hasIO() ) {
884 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
885 if(IsSelected(IO,aSel)) {
886 // This IO is already in the selection
888 aSel->RemoveIObject(IO);
893 this->HighlightProp( NULL );
894 aSel->ClearIObjects();
896 aSel->AddIObject( IO, false );
899 // No selection clear all
900 this->PropPicked = 0;
901 this->HighlightProp( NULL );
902 aSel->ClearIObjects();
905 m_Interactor->EndPickCallback();
907 //processing rectangle selection
908 QString aComponentDataType = SUIT_Application::getDesktop()->getComponentDataType();
909 if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return;
910 m_Interactor->StartPickCallback();
913 this->PropPicked = 0;
914 this->HighlightProp( NULL );
915 aSel->ClearIObjects();
919 // vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
920 QRect rect(myPoint, myOtherPoint);
921 rect = rect.normalize();
923 m_Interactor->GetSize(w, h);
926 y1 = h - rect.top() - 1;
928 y2 = h - rect.bottom() - 1;
930 switch (aSelectionMode) {
931 case NodeSelection: {
932 if ( vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(m_Interactor->GetPicker()) ) {
933 vtkActorCollection* aListActors = this->CurrentRenderer->GetActors();
934 aListActors->InitTraversal();
935 while (vtkActor* aActor = aListActors->GetNextActor()) {
936 if (!aActor->GetVisibility())
938 if(SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor)) {
939 if (SActor->hasIO()) {
940 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
943 if (aSelActiveCompOnly && aComponentDataType != IO->getComponentDataType())
945 if (vtkDataSet* aDataSet = SActor->GetInput()) {
946 SALOME_Selection::TContainerOfId anIndices;
947 for(int i = 0; i < aDataSet->GetNumberOfPoints(); i++) {
949 aDataSet->GetPoint(i,aPoint);
950 if (IsInRect(aPoint,x1,y1,x2,y2)){
952 ComputeWorldToDisplay(aPoint[0],aPoint[1],aPoint[2],aDisp);
953 if(aPointPicker->Pick(aDisp[0],aDisp[1],0.0,CurrentRenderer)){
954 if(vtkActorCollection *anActorCollection = aPointPicker->GetActors()){
955 if(anActorCollection->IsItemPresent(SActor)){
956 float aPickedPoint[3];
957 aPointPicker->GetMapperPosition(aPickedPoint);
958 vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint);
959 if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ){
960 int anObjId = SActor->GetNodeObjId(aVtkId);
961 anIndices.insert(anObjId);
968 if (!anIndices.empty()) {
969 aSel->AddOrRemoveIndex(IO, anIndices, true, false);
970 aSel->AddIObject(IO, false);
973 aSel->RemoveIObject(IO, false);
983 case EdgeOfCellSelection:
986 case VolumeSelection:
988 vtkSmartPointer<VTKViewer_CellRectPicker> picker = VTKViewer_CellRectPicker::New();
989 picker->SetTolerance(0.001);
990 picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
992 vtkActorCollection* aListActors = picker->GetActors();
993 aListActors->InitTraversal();
994 while(vtkActor* aActor = aListActors->GetNextActor()) {
995 if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
996 if (aSActor->hasIO()) {
997 Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
998 if (aSelActiveCompOnly && aComponentDataType != aIO->getComponentDataType())
1000 VTKViewer_CellDataSet cellList = picker->GetCellData(aActor);
1001 if ( !cellList.empty() ) {
1002 if(MYDEBUG) INFOS ( " NAME Actor : " << aSActor->getName() );
1003 SALOME_Selection::TContainerOfId anIndexes;
1004 VTKViewer_CellDataSet::iterator it;
1005 for ( it = cellList.begin(); it != cellList.end(); ++it ) {
1006 int aCellId = (*it).cellId;
1008 if ( !IsValid( aSActor, aCellId ) )
1011 int anObjId = aSActor->GetElemObjId(aCellId);
1013 if ( CheckDimensionId(aSelectionMode,aSActor,anObjId) ) {
1014 anIndexes.insert(anObjId);
1018 aSel->AddOrRemoveIndex(aIO, anIndexes, true, false);
1019 aSel->AddIObject(aIO, false);
1026 case ActorSelection: // objects selection
1028 vtkSmartPointer<VTKViewer_RectPicker> picker = VTKViewer_RectPicker::New();
1029 picker->SetTolerance(0.001);
1030 picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
1032 vtkActorCollection* aListActors = picker->GetActors();
1033 SALOME_ListIO aListIO;
1034 aListActors->InitTraversal();
1035 while(vtkActor* aActor = aListActors->GetNextActor()) {
1036 if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
1037 if (aSActor->hasIO()) {
1038 Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
1039 if (!IsStored(aIO,aListIO))
1040 aListIO.Append(aIO);
1044 if (!aListIO.IsEmpty()) {
1045 SALOME_ListIteratorOfListIO It(aListIO);
1046 for(;It.More();It.Next()) {
1047 Handle(SALOME_InteractiveObject) IOS = It.Value();
1049 aSel->AddIObject( IOS, false );
1054 m_Interactor->EndPickCallback();
1056 aActiveStudy->update3dViewers();
1060 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
1061 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
1062 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
1063 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
1065 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
1068 m_Interactor->GetSize(w, h);
1070 y = h - myPoint.y() - 1;
1075 if (myGUIWindow) myGUIWindow->update();
1079 // called during viewer operation when user moves mouse (!put necessary processing here!)
1080 void VTKViewer_InteractorStyle::onOperation(QPoint mousePos)
1082 if (!myGUIWindow) return;
1084 GetInteractor()->GetSize(w, h);
1086 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
1088 // processing panning
1089 //this->FindPokedCamera(mousePos.x(), mousePos.y());
1090 this->PanXY(mousePos.x(), myPoint.y(), myPoint.x(), mousePos.y());
1094 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
1096 // processing zooming
1097 //this->FindPokedCamera(mousePos.x(), mousePos.y());
1098 this->DollyXY(mousePos.x() - myPoint.x(), mousePos.y() - myPoint.y());
1102 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
1104 // processing rotation
1105 //this->FindPokedCamera(mousePos.x(), mousePos.y());
1106 this->RotateXY(mousePos.x() - myPoint.x(), myPoint.y() - mousePos.y());
1110 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
1112 // processing spinning
1113 //this->FindPokedCamera(mousePos.x(), mousePos.y());
1114 this->SpinXY(mousePos.x(), mousePos.y(), myPoint.x(), myPoint.y());
1118 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
1122 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
1125 setCursor(VTK_INTERACTOR_STYLE_CAMERA_SELECT);
1127 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
1129 QPainter p(myGUIWindow);
1130 p.setPen(Qt::lightGray);
1131 p.setRasterOp(Qt::XorROP);
1132 p.drawRect(QRect(myPoint, myOtherPoint));
1133 myOtherPoint = mousePos;
1134 p.drawRect(QRect(myPoint, myOtherPoint));
1138 this->LastPos[0] = mousePos.x();
1139 this->LastPos[1] = h - mousePos.y() - 1;
1142 // called when selection mode changed (!put necessary initialization here!)
1143 void VTKViewer_InteractorStyle::OnSelectionModeChanged()
1146 myPreSelectionActor->SetVisibility(false);
1147 myElemId = myEdgeId = myNodeId = -1;
1148 mySelectedActor = NULL;
1151 // called when user moves mouse inside viewer window and there is no active viewer operation
1152 // (!put necessary processing here!)
1153 void VTKViewer_InteractorStyle::onCursorMove(QPoint mousePos) {
1154 // processing highlighting
1155 // SUIT_Study* anActiveStudy = SUIT_Application::getDesktop()->getActiveStudy();
1156 // SALOME_Selection* Sel = SALOME_Selection::Selection( anActiveStudy->getSelection() );
1157 // Selection_Mode aSelectionMode = Sel->SelectionMode();
1160 m_Interactor->GetSize(w, h);
1161 x = mousePos.x(); y = h - mousePos.y() - 1;
1163 this->FindPokedRenderer(x,y);
1164 m_Interactor->StartPickCallback();
1165 myPreSelectionActor->SetVisibility(false);
1167 vtkPicker* aPicker = vtkPicker::SafeDownCast(m_Interactor->GetPicker());
1168 aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
1170 SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
1172 if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
1173 int aVtkId = picker->GetCellId();
1174 if ( aVtkId >= 0 ) {
1175 int anObjId = SActor->GetElemObjId(aVtkId);
1176 if ( SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) {
1177 bool anIsSameObjId = (mySelectedActor == SActor && myElemId == anObjId);
1178 bool aResult = anIsSameObjId;
1179 if(!anIsSameObjId) {
1180 if(aSelectionMode != EdgeOfCellSelection) {
1181 aResult = CheckDimensionId(aSelectionMode,SActor,anObjId);
1183 mySelectedActor = SActor;
1185 if(MYDEBUG) INFOS(" CellId : "<<anObjId);
1186 m_Interactor->setCellData(anObjId,SActor,myPreSelectionActor);
1190 if(aSelectionMode == EdgeOfCellSelection){
1191 int anEdgeId = GetEdgeId(picker,SActor,anObjId);
1192 bool anIsSameEdgeId = (myEdgeId != anEdgeId) && anIsSameObjId;
1193 aResult = anIsSameEdgeId;
1194 if(!anIsSameEdgeId) {
1195 aResult = (anEdgeId >= 0);
1197 mySelectedActor = SActor;
1198 myEdgeId = anEdgeId;
1200 if(MYDEBUG) INFOS(" CellId : "<<anObjId<<"; EdgeId : "<<anEdgeId);
1201 m_Interactor->setEdgeData(anObjId,SActor,-anEdgeId-1,myPreSelectionActor);
1206 myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
1207 myPreSelectionActor->SetVisibility(true);
1212 else if (vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker)) {
1213 int aVtkId = picker->GetPointId();
1214 if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) {
1215 if ( SActor && SActor->hasIO() ) {
1216 int anObjId = SActor->GetNodeObjId(aVtkId);
1217 bool anIsSameObjId = (mySelectedActor == SActor && myNodeId == anObjId);
1218 if(!anIsSameObjId) {
1219 mySelectedActor = SActor;
1221 if(MYDEBUG) INFOS(" PointId : "<<anObjId);
1222 m_Interactor->setPointData(anObjId,SActor,myPreSelectionActor);
1224 myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
1225 myPreSelectionActor->SetVisibility(true);
1229 else if ( vtkPicker::SafeDownCast(aPicker) ) {
1231 if ( myPreViewActor != SActor ) {
1232 if ( myPreViewActor != NULL ) {
1233 myPreViewActor->SetPreSelected( false );
1235 myPreViewActor = SActor;
1237 if ( SActor->hasIO() ) {
1238 Handle( SALOME_InteractiveObject) IO = SActor->getIO();
1239 if ( !IsSelected(IO,Sel) ) {
1240 // Find All actors with same IO
1241 vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
1242 theActors->InitTraversal();
1243 while( vtkActor *ac = theActors->GetNextActor() ) {
1244 if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
1245 if ( anActor->hasIO() ) {
1246 Handle(SALOME_InteractiveObject) IOS = anActor->getIO();
1247 if(IO->isSame(IOS)) {
1248 anActor->SetPreSelected( true );
1253 //if(MYDEBUG) INFOS ( " NAME PREVIEW " << SActor->getName() );
1258 myPreViewActor = NULL;
1259 vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
1260 theActors->InitTraversal();
1261 while( vtkActor *ac = theActors->GetNextActor() ) {
1262 if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
1263 anActor->SetPreSelected( false );
1268 m_Interactor->EndPickCallback();
1269 //m_Interactor->Render();
1270 myGUIWindow->update();
1272 this->LastPos[0] = x;
1273 this->LastPos[1] = y;*/
1276 // called on finsh GlobalPan operation
1277 void VTKViewer_InteractorStyle::Place(const int theX, const int theY)
1279 if (this->CurrentRenderer == NULL) {
1284 int *aSize = this->CurrentRenderer->GetRenderWindow()->GetSize();
1285 int centerX = aSize[0]/2;
1286 int centerY = aSize[1]/2;
1288 TranslateView(centerX, centerY, theX, theY);
1290 // restore zoom scale
1291 vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
1292 cam->SetParallelScale(myScale);
1293 ::ResetCameraClippingRange(this->CurrentRenderer);
1295 if (myGUIWindow) myGUIWindow->update();
1301 // Translates view from Point to Point
1302 void VTKViewer_InteractorStyle::TranslateView(int toX, int toY, int fromX, int fromY)
1304 vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
1305 double viewFocus[4], focalDepth, viewPoint[3];
1306 float newPickPoint[4], oldPickPoint[4], motionVector[3];
1307 cam->GetFocalPoint(viewFocus);
1309 this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1],
1310 viewFocus[2], viewFocus);
1311 focalDepth = viewFocus[2];
1313 this->ComputeDisplayToWorld(double(toX), double(toY),
1314 focalDepth, newPickPoint);
1315 this->ComputeDisplayToWorld(double(fromX),double(fromY),
1316 focalDepth, oldPickPoint);
1318 // camera motion is reversed
1319 motionVector[0] = oldPickPoint[0] - newPickPoint[0];
1320 motionVector[1] = oldPickPoint[1] - newPickPoint[1];
1321 motionVector[2] = oldPickPoint[2] - newPickPoint[2];
1323 cam->GetFocalPoint(viewFocus);
1324 cam->GetPosition(viewPoint);
1325 cam->SetFocalPoint(motionVector[0] + viewFocus[0],
1326 motionVector[1] + viewFocus[1],
1327 motionVector[2] + viewFocus[2]);
1328 cam->SetPosition(motionVector[0] + viewPoint[0],
1329 motionVector[1] + viewPoint[1],
1330 motionVector[2] + viewPoint[2]);
1334 /// Checks: is the given Actor within display coordinates?
1335 bool VTKViewer_InteractorStyle::IsInRect(vtkActor* theActor,
1336 const int left, const int top,
1337 const int right, const int bottom)
1339 float* aBounds = theActor->GetBounds();
1340 float aMin[3], aMax[3];
1341 ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
1342 ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
1343 if (aMin[0] > aMax[0]) {
1344 float aBuf = aMin[0];
1348 if (aMin[1] > aMax[1]) {
1349 float aBuf = aMin[1];
1354 return ((aMin[0]>left) && (aMax[0]<right) && (aMin[1]>bottom) && (aMax[1]<top));
1358 /// Checks: is the given Cell within display coordinates?
1359 bool VTKViewer_InteractorStyle::IsInRect(vtkCell* theCell,
1360 const int left, const int top,
1361 const int right, const int bottom)
1363 float* aBounds = theCell->GetBounds();
1364 float aMin[3], aMax[3];
1365 ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
1366 ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
1367 if (aMin[0] > aMax[0]) {
1368 float aBuf = aMin[0];
1372 if (aMin[1] > aMax[1]) {
1373 float aBuf = aMin[1];
1378 return ((aMin[0]>left) && (aMax[0]<right) && (aMin[1]>bottom) && (aMax[1]<top));
1382 bool VTKViewer_InteractorStyle::IsInRect(float* thePoint,
1383 const int left, const int top,
1384 const int right, const int bottom)
1387 ComputeWorldToDisplay(thePoint[0], thePoint[1], thePoint[2], aPnt);
1389 return ((aPnt[0]>left) && (aPnt[0]<right) && (aPnt[1]>bottom) && (aPnt[1]<top));
1392 void VTKViewer_InteractorStyle::SetFilter( const Handle(VTKViewer_Filter)& theFilter )
1394 myFilters[ theFilter->GetId() ] = theFilter;
1397 bool VTKViewer_InteractorStyle::IsFilterPresent( const int theId )
1399 return myFilters.find( theId ) != myFilters.end();
1402 void VTKViewer_InteractorStyle::RemoveFilter( const int theId )
1404 if ( IsFilterPresent( theId ) )
1405 myFilters.erase( theId );
1409 bool VTKViewer_InteractorStyle::IsValid( VTKViewer_Actor* theActor,
1411 const bool theIsNode )
1413 std::map<int, Handle(VTKViewer_Filter)>::const_iterator anIter;
1414 for ( anIter = myFilters.begin(); anIter != myFilters.end(); ++anIter )
1416 const Handle(VTKViewer_Filter)& aFilter = anIter->second;
1417 if ( theIsNode == aFilter->IsNodeFilter() &&
1418 !aFilter->IsValid( theActor, theId ) )
1424 Handle(VTKViewer_Filter) VTKViewer_InteractorStyle::GetFilter( const int theId )
1426 return IsFilterPresent( theId ) ? myFilters[ theId ] : Handle(VTKViewer_Filter)();
1429 void VTKViewer_InteractorStyle::IncrementalPan( const int incrX, const int incrY )
1431 this->PanXY( incrX, incrY, 0, 0 );
1434 void VTKViewer_InteractorStyle::IncrementalZoom( const int incr )
1436 this->DollyXY( incr, incr );
1439 void VTKViewer_InteractorStyle::IncrementalRotate( const int incrX, const int incrY )
1441 this->RotateXY( incrX, -incrY );