1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SALOME VTKViewer : build VTK viewer into Salome desktop
24 // File : VTKViewer_InteractorStyle.cxx
25 // Author : Christophe ATTANASIO
27 #include "VTKViewer_InteractorStyle.h"
29 #include "VTKViewer_Actor.h"
30 #include "VTKViewer_Utilities.h"
31 #include "VTKViewer_Trihedron.h"
32 #include "VTKViewer_ViewWindow.h"
33 #include "VTKViewer_RenderWindow.h"
34 #include "VTKViewer_RenderWindowInteractor.h"
36 #include <vtkObjectFactory.h>
38 #include <vtkCommand.h>
39 #include <vtkCamera.h>
40 #include <vtkRenderer.h>
41 #include <vtkPicker.h>
42 #include <vtkPointPicker.h>
43 #include <vtkCellPicker.h>
45 #include <vtkMapper.h>
46 #include <vtkDataSet.h>
47 #include <vtkSmartPointer.h>
48 #include <vtkProperty.h>
50 #include <QApplication>
51 #include <QRubberBand>
56 static int GetEdgeId(vtkPicker *thePicker, SALOME_Actor *theActor, int theObjId){
58 if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) {
59 float aPickPosition[3];
60 thePicker->GetPickPosition(aPickPosition);
61 float aMinDist = 1000000.0, aDist = 0;
62 for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
63 if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){
64 int subId; float pcoords[3], closestPoint[3], weights[3];
65 aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
66 if (aDist < aMinDist) {
77 vtkStandardNewMacro(VTKViewer_InteractorStyle);
81 VTKViewer_InteractorStyle::VTKViewer_InteractorStyle()
84 this->MotionFactor = 10.0;
85 this->State = VTK_INTERACTOR_STYLE_CAMERA_NONE;
86 this->RadianToDegree = 180.0 / vtkMath::Pi();
87 this->ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE;
90 myPreSelectionActor = VTKViewer_Actor::New();
91 myPreSelectionActor->GetProperty()->SetColor(0,1,1);
92 myPreSelectionActor->GetProperty()->SetLineWidth(5);
93 myPreSelectionActor->GetProperty()->SetPointSize(5);
97 OnSelectionModeChanged();
102 VTKViewer_InteractorStyle::~VTKViewer_InteractorStyle()
104 m_ViewWnd->RemoveActor(myPreSelectionActor);
109 /*!Set preselection properties.
110 *\param theRed - red color.
111 *\param theGreen - green color.
112 *\param theBlue - blue color.
113 *\param theWidth - width..
115 void VTKViewer_InteractorStyle::setPreselectionProp(const double& theRed, const double& theGreen,
116 const double& theBlue, const int& theWidth)
118 if ( myPreSelectionActor->GetProperty() == 0 )
120 myPreSelectionActor->GetProperty()->SetColor(theRed, theGreen, theBlue);
121 myPreSelectionActor->GetProperty()->SetLineWidth(theWidth);
122 myPreSelectionActor->GetProperty()->SetPointSize(theWidth);
126 /*!Set render window interactor
127 *\param theInteractor - interactor.
129 void VTKViewer_InteractorStyle::SetInteractor(vtkRenderWindowInteractor *theInteractor){
130 m_Interactor = dynamic_cast<VTKViewer_RenderWindowInteractor*>(theInteractor);
131 Superclass::SetInteractor(theInteractor);
136 *\param theViewWnd - SALOME VTKViewer_ViewWindow
138 void VTKViewer_InteractorStyle::setViewWnd(VTKViewer_ViewWindow* theViewWnd ){
139 m_ViewWnd = theViewWnd;
140 m_ViewWnd->AddActor(myPreSelectionActor);
141 myPreSelectionActor->Delete();
146 *\param theWindow - QWidget window.
148 void VTKViewer_InteractorStyle::setGUIWindow(QWidget* theWindow){
149 myGUIWindow = theWindow;
154 *\param theTrihedron - SALOME VTKViewer_Trihedron
156 void VTKViewer_InteractorStyle::setTriedron(VTKViewer_Trihedron* theTrihedron){
157 m_Trihedron = theTrihedron;
164 void VTKViewer_InteractorStyle::RotateXY(int dx, int dy)
170 if (this->CurrentRenderer == NULL)
175 int *size = this->CurrentRenderer->GetRenderWindow()->GetSize();
176 this->DeltaElevation = -20.0 / size[1];
177 this->DeltaAzimuth = -20.0 / size[0];
179 rxf = (double)dx * this->DeltaAzimuth * this->MotionFactor;
180 ryf = (double)dy * this->DeltaElevation * this->MotionFactor;
182 cam = this->CurrentRenderer->GetActiveCamera();
185 cam->OrthogonalizeViewUp();
186 ::ResetCameraClippingRange(this->CurrentRenderer);
187 //this->Interactor->Render();
188 myGUIWindow->update();
191 void VTKViewer_InteractorStyle::PanXY(int x, int y, int oldX, int oldY)
193 TranslateView(x, y, oldX, oldY);
194 //this->Interactor->Render();
195 myGUIWindow->update();
199 /*! Move the position of the camera along the direction of projection. (dx,dy)*/
200 void VTKViewer_InteractorStyle::DollyXY(int dx, int dy)
202 if (this->CurrentRenderer == NULL) return;
204 double dxf = this->MotionFactor * (double)(dx) / (double)(this->CurrentRenderer->GetCenter()[1]);
205 double dyf = this->MotionFactor * (double)(dy) / (double)(this->CurrentRenderer->GetCenter()[1]);
207 double zoomFactor = pow((double)1.1, dxf + dyf);
209 vtkCamera *aCam = this->CurrentRenderer->GetActiveCamera();
210 if (aCam->GetParallelProjection())
211 aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor);
213 aCam->Dolly(zoomFactor);
214 ::ResetCameraClippingRange(this->CurrentRenderer);
217 //this->Interactor->Render();
218 myGUIWindow->update();
221 void VTKViewer_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY)
225 if (this->CurrentRenderer == NULL)
230 double newAngle = atan2((double)(y - this->CurrentRenderer->GetCenter()[1]),
231 (double)(x - this->CurrentRenderer->GetCenter()[0]));
232 double oldAngle = atan2((double)(oldY -this->CurrentRenderer->GetCenter()[1]),
233 (double)(oldX - this->CurrentRenderer->GetCenter()[0]));
235 newAngle *= this->RadianToDegree;
236 oldAngle *= this->RadianToDegree;
238 cam = this->CurrentRenderer->GetActiveCamera();
239 cam->Roll(newAngle - oldAngle);
240 cam->OrthogonalizeViewUp();
242 //this->Interactor->Render();
243 myGUIWindow->update();
247 /*!On mouse move event.
248 *\param ctrl - CTRL (not used)
249 *\param shift - SHIFT (on/off - integer 0/1)
250 *\param x - x coordinate
251 *\param y - y coordinate
253 void VTKViewer_InteractorStyle::OnMouseMove(int vtkNotUsed(ctrl),
257 myShiftState = shift;
258 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
259 onOperation(QPoint(x, y));
260 else if (ForcedState == VTK_INTERACTOR_STYLE_CAMERA_NONE)
261 onCursorMove(QPoint(x, y));
265 /*!On Left button down event.
266 *\param ctrl - CTRL (on/off - integer 0/1)
267 *\param shift - SHIFT (on/off - integer 0/1)
268 *\param x - x coordinate
269 *\param y - y coordinate
271 void VTKViewer_InteractorStyle::OnLeftButtonDown(int ctrl, int shift,
274 if (this->HasObserver(vtkCommand::LeftButtonPressEvent)) {
275 this->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL);
278 this->FindPokedRenderer(x, y);
279 if (this->CurrentRenderer == NULL) {
282 myShiftState = shift;
283 // finishing current viewer operation
284 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
286 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
288 myOtherPoint = myPoint = QPoint(x, y);
289 if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
290 startOperation(ForcedState);
293 startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
295 startOperation(VTK_INTERACTOR_STYLE_CAMERA_SELECT);
301 /*!On left button up event.
302 *\param ctrl - CTRL (not used)
303 *\param shift - SHIFT (on/off - integer 0/1)
304 *\param x - x coordinate (not used)
305 *\param y - y coordinate (not used)
307 void VTKViewer_InteractorStyle::OnLeftButtonUp(int vtkNotUsed(ctrl),
312 myShiftState = shift;
313 // finishing current viewer operation
314 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
316 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
321 /*!On left button up event.
322 *\param ctrl - CTRL (on/off - integer 0/1)
323 *\param shift - SHIFT (on/off - integer 0/1)
324 *\param x - x coordinate
325 *\param y - y coordinate
327 void VTKViewer_InteractorStyle::OnMiddleButtonDown(int ctrl,
331 if (this->HasObserver(vtkCommand::MiddleButtonPressEvent))
333 this->InvokeEvent(vtkCommand::MiddleButtonPressEvent,NULL);
336 this->FindPokedRenderer(x, y);
337 if (this->CurrentRenderer == NULL)
341 myShiftState = shift;
342 // finishing current viewer operation
343 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
345 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
347 myOtherPoint = myPoint = QPoint(x, y);
348 if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
349 startOperation(ForcedState);
353 startOperation(VTK_INTERACTOR_STYLE_CAMERA_PAN);
358 /*!On middle button up event.
359 *\param ctrl - CTRL (not used)
360 *\param shift - SHIFT (on/off - integer 0/1)
361 *\param x - x coordinate (not used)
362 *\param y - y coordinate (not used)
364 void VTKViewer_InteractorStyle::OnMiddleButtonUp(int vtkNotUsed(ctrl),
369 myShiftState = shift;
370 // finishing current viewer operation
371 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
373 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
378 /*!On right button down event.
379 *\param ctrl - CTRL (on/off - integer 0/1)
380 *\param shift - SHIFT (on/off - integer 0/1)
381 *\param x - x coordinate
382 *\param y - y coordinate
384 void VTKViewer_InteractorStyle::OnRightButtonDown(int ctrl,
388 if (this->HasObserver(vtkCommand::RightButtonPressEvent))
390 this->InvokeEvent(vtkCommand::RightButtonPressEvent,NULL);
393 this->FindPokedRenderer(x, y);
394 if (this->CurrentRenderer == NULL)
398 myShiftState = shift;
399 // finishing current viewer operation
400 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
402 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
404 myOtherPoint = myPoint = QPoint(x, y);
405 if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
406 startOperation(ForcedState);
410 startOperation(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
414 /*!On right button up event.
415 *\param ctrl - CTRL (not used)
416 *\param shift - SHIFT (on/off - integer 0/1)
417 *\param x - x coordinate (not used)
418 *\param y - y coordinate (not used)
420 void VTKViewer_InteractorStyle::OnRightButtonUp(int vtkNotUsed(ctrl),
425 myShiftState = shift;
426 // finishing current viewer operation
427 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
429 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
433 /*! @name XPM - x pixmaps. */
435 /*!Image Zoom cursor*/
436 const char* imageZoomCursor[] = {
441 "................................",
442 "................................",
443 ".#######........................",
444 "..aaaaaaa.......................",
445 "................................",
446 ".............#####..............",
447 "...........##.aaaa##............",
448 "..........#.aa.....a#...........",
449 ".........#.a.........#..........",
450 ".........#a..........#a.........",
451 "........#.a...........#.........",
452 "........#a............#a........",
453 "........#a............#a........",
454 "........#a............#a........",
455 "........#a............#a........",
456 ".........#...........#.a........",
457 ".........#a..........#a.........",
458 ".........##.........#.a.........",
459 "........#####.....##.a..........",
460 ".......###aaa#####.aa...........",
461 "......###aa...aaaaa.......#.....",
462 ".....###aa................#a....",
463 "....###aa.................#a....",
464 "...###aa...............#######..",
465 "....#aa.................aa#aaaa.",
466 ".....a....................#a....",
467 "..........................#a....",
468 "...........................a....",
469 "................................",
470 "................................",
471 "................................",
472 "................................"};
474 /*!Image rotate cursor*/
475 const char* imageRotateCursor[] = {
480 "................................",
481 "................................",
482 "................................",
483 "................................",
484 "........#.......................",
485 ".......#.a......................",
486 "......#######...................",
487 ".......#aaaaa#####..............",
488 "........#..##.a#aa##........##..",
489 ".........a#.aa..#..a#.....##.aa.",
490 ".........#.a.....#...#..##.aa...",
491 ".........#a.......#..###.aa.....",
492 "........#.a.......#a..#aa.......",
493 "........#a.........#..#a........",
494 "........#a.........#a.#a........",
495 "........#a.........#a.#a........",
496 "........#a.........#a.#a........",
497 ".........#.........#a#.a........",
498 "........##a........#a#a.........",
499 "......##.a#.......#.#.a.........",
500 "....##.aa..##.....##.a..........",
501 "..##.aa.....a#####.aa...........",
502 "...aa.........aaa#a.............",
503 "................#.a.............",
504 "...............#.a..............",
505 "..............#.a...............",
506 "...............a................",
507 "................................",
508 "................................",
509 "................................",
510 "................................",
511 "................................"};
514 /*! Loads cursors for viewer operations - zoom, pan, etc...*/
515 void VTKViewer_InteractorStyle::loadCursors()
517 myDefCursor = QCursor(Qt::ArrowCursor);
518 myHandCursor = QCursor(Qt::PointingHandCursor);
519 myPanCursor = QCursor(Qt::SizeAllCursor);
520 myZoomCursor = QCursor(QPixmap(imageZoomCursor));
521 myRotateCursor = QCursor(QPixmap(imageRotateCursor));
522 mySpinCursor = QCursor(QPixmap(imageRotateCursor)); // temporarly !!!!!!
523 myGlobalPanCursor = QCursor(Qt::CrossCursor);
524 myCursorState = false;
528 /*! event filter - controls mouse and keyboard events during viewer operations*/
529 bool VTKViewer_InteractorStyle::eventFilter(QObject* object, QEvent* event)
531 if (!myGUIWindow) return false;
532 if ( (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::KeyPress) && object != myGUIWindow)
534 qApp->removeEventFilter(this);
535 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
537 return QObject::eventFilter(object, event);
541 /*! starts Zoom operation (e.g. through menu command)*/
542 void VTKViewer_InteractorStyle::startZoom()
544 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
547 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
549 setCursor(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
550 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ZOOM;
551 qApp->installEventFilter(this);
555 /*! starts Pan operation (e.g. through menu command)*/
556 void VTKViewer_InteractorStyle::startPan()
558 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
561 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
563 setCursor(VTK_INTERACTOR_STYLE_CAMERA_PAN);
564 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_PAN;
565 qApp->installEventFilter(this);
568 /*! starts Rotate operation (e.g. through menu command)*/
569 void VTKViewer_InteractorStyle::startRotate()
571 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
574 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
576 setCursor(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
577 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ROTATE;
578 qApp->installEventFilter(this);
582 /*! starts Spin operation (e.g. through menu command)*/
583 void VTKViewer_InteractorStyle::startSpin()
585 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
588 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
590 setCursor(VTK_INTERACTOR_STYLE_CAMERA_SPIN);
591 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_SPIN;
592 qApp->installEventFilter(this);
597 /*! starts Fit Area operation (e.g. through menu command)*/
598 void VTKViewer_InteractorStyle::startFitArea()
600 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
603 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
605 setCursor(VTK_INTERACTOR_STYLE_CAMERA_FIT);
606 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_FIT;
607 qApp->installEventFilter(this);
612 void VTKViewer_InteractorStyle::ViewFitAll() {
613 int aTriedronWasVisible = false;
615 aTriedronWasVisible = m_Trihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
616 if(aTriedronWasVisible) m_Trihedron->VisibilityOff();
619 if(m_Trihedron->GetVisibleActorCount(CurrentRenderer)){
620 m_Trihedron->VisibilityOff();
621 ::ResetCamera(CurrentRenderer);
623 m_Trihedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn);
624 ::ResetCamera(CurrentRenderer,true);
626 if(aTriedronWasVisible) m_Trihedron->VisibilityOn();
627 else m_Trihedron->VisibilityOff();
628 ::ResetCameraClippingRange(CurrentRenderer);
632 /*! starts Global Panning operation (e.g. through menu command)*/
633 void VTKViewer_InteractorStyle::startGlobalPan()
635 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
638 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
640 setCursor(VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN);
641 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN;
643 // store current zoom scale
644 vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
645 myScale = cam->GetParallelScale();
649 if (myGUIWindow) myGUIWindow->update();
651 qApp->installEventFilter(this);
655 /*!\retval TRUE if needs redrawing*/
656 bool VTKViewer_InteractorStyle::needsRedrawing()
658 return State == VTK_INTERACTOR_STYLE_CAMERA_ZOOM ||
659 State == VTK_INTERACTOR_STYLE_CAMERA_PAN ||
660 State == VTK_INTERACTOR_STYLE_CAMERA_ROTATE ||
661 State == VTK_INTERACTOR_STYLE_CAMERA_SPIN ||
662 State == VTK_INTERACTOR_STYLE_CAMERA_NONE;
666 /*! fits viewer contents to rectangle
667 *\param left - left side
668 *\param top - top side
669 *\param right - right side
670 *\param bottom - bottom side
672 void VTKViewer_InteractorStyle::fitRect(const int left,
677 if (this->CurrentRenderer == NULL) return;
680 int x = (left + right)/2;
681 int y = (top + bottom)/2;
682 int *aSize = this->CurrentRenderer->GetRenderWindow()->GetSize();
683 int oldX = aSize[0]/2;
684 int oldY = aSize[1]/2;
685 TranslateView(oldX, oldY, x, y);
688 double dxf = (double)(aSize[0]) / (double)(abs(right - left));
689 double dyf = (double)(aSize[1]) / (double)(abs(bottom - top));
690 double zoomFactor = (dxf + dyf)/2 ;
692 vtkCamera *aCam = this->CurrentRenderer->GetActiveCamera();
693 if(aCam->GetParallelProjection())
694 aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor);
696 aCam->Dolly(zoomFactor);
697 ::ResetCameraClippingRange(this->CurrentRenderer);
700 myGUIWindow->update();
704 /*! starts viewer operation (!internal usage!)*/
705 void VTKViewer_InteractorStyle::startOperation(int operation)
709 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
710 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
711 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
712 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
713 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
714 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
715 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
716 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
717 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
719 if (State != VTK_INTERACTOR_STYLE_CAMERA_SELECT)
720 setCursor(operation);
723 case VTK_INTERACTOR_STYLE_CAMERA_NONE:
725 setCursor(VTK_INTERACTOR_STYLE_CAMERA_NONE);
726 State = ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE;
732 /*! sets proper cursor for window when viewer operation is activated*/
733 void VTKViewer_InteractorStyle::setCursor(const int operation)
735 if (!myGUIWindow) return;
738 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
739 myGUIWindow->setCursor(myZoomCursor);
740 myCursorState = true;
742 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
743 myGUIWindow->setCursor(myPanCursor);
744 myCursorState = true;
746 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
747 myGUIWindow->setCursor(myRotateCursor);
748 myCursorState = true;
750 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
751 myGUIWindow->setCursor(mySpinCursor);
752 myCursorState = true;
754 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
755 myGUIWindow->setCursor(myGlobalPanCursor);
756 myCursorState = true;
758 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
759 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
760 myGUIWindow->setCursor(myHandCursor);
761 myCursorState = true;
763 case VTK_INTERACTOR_STYLE_CAMERA_NONE:
765 myGUIWindow->setCursor(myDefCursor);
766 myCursorState = false;
772 Draws rectangle by starting and current points
774 void VTKViewer_InteractorStyle::drawRect()
777 myRectBand = new QRubberBand( QRubberBand::Rectangle, myGUIWindow );
779 palette.setColor(myRectBand->foregroundRole(), Qt::white);
780 myRectBand->setPalette(palette);
784 QRect aRect(myPoint, myOtherPoint);
785 myRectBand->setGeometry( aRect );
786 myRectBand->setVisible( aRect.isValid() );
790 \brief Delete rubber band on the end on the dragging operation.
792 void VTKViewer_InteractorStyle::endDrawRect()
798 /*! called when viewer operation started (!put necessary initialization here!)*/
799 void VTKViewer_InteractorStyle::onStartOperation()
801 if (!myGUIWindow) return;
802 // VSV: LOD actor activisation
803 // this->Interactor->GetRenderWindow()->SetDesiredUpdateRate(this->Interactor->GetDesiredUpdateRate());
805 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
806 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
811 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
812 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
813 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
814 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
815 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
821 /*! called when viewer operation finished (!put necessary post-processing here!)*/
822 void VTKViewer_InteractorStyle::onFinishOperation()
824 if (!myGUIWindow) return;
827 // SUIT_Study* aActiveStudy = SUIT_Application::getDesktop()->getActiveStudy();
828 // SALOME_Selection* aSel = SALOME_Selection::Selection( aActiveStudy->getSelection() );
830 // VSV: LOD actor activisation
831 // rwi->GetRenderWindow()->SetDesiredUpdateRate(rwi->GetStillUpdateRate());
833 // Selection_Mode aSelectionMode = aSel->SelectionMode();
834 // bool aSelActiveCompOnly = aSel->IsSelectActiveCompOnly();
837 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
838 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
840 QPainter p(myGUIWindow);
841 p.setPen(Qt::lightGray);
842 p.setRasterOp(Qt::XorROP);
843 QRect rect(myPoint, myOtherPoint);
845 rect = rect.normalize();
846 if (State == VTK_INTERACTOR_STYLE_CAMERA_FIT) {
847 // making fit rect opeation
849 m_Interactor->GetSize(w, h);
852 y1 = h - rect.top() - 1;
854 y2 = h - rect.bottom() - 1;
855 fitRect(x1, y1, x2, y2);
858 if (myPoint == myOtherPoint) {
859 // process point selection
861 m_Interactor->GetSize(w, h);
863 y = h - myPoint.y() - 1;
865 this->FindPokedRenderer(x, y);
866 m_Interactor->StartPickCallback();
868 vtkPicker* aPicker = vtkPicker::SafeDownCast(m_Interactor->GetPicker());
869 aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
871 SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
873 if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
874 int aVtkId = picker->GetCellId();
875 if ( aVtkId >= 0 && SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) {
876 int anObjId = SActor->GetElemObjId(aVtkId);
878 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
879 if(aSelectionMode != EdgeOfCellSelection) {
880 if(CheckDimensionId(aSelectionMode,SActor,anObjId)){
881 if (IsSelected(IO,aSel)) {
882 // This IO is already in the selection
883 aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
886 this->HighlightProp( NULL );
887 aSel->ClearIObjects();
889 aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
890 aSel->AddIObject( IO, false );
895 this->HighlightProp( NULL );
896 aSel->ClearIObjects();
898 int anEdgeId = GetEdgeId(picker,SActor,anObjId);
900 aSel->AddOrRemoveIndex( IO, anObjId, true, false);
901 aSel->AddOrRemoveIndex( IO, -anEdgeId-1, true, true );
902 aSel->AddIObject( IO, false );
907 this->HighlightProp( NULL );
908 aSel->ClearIObjects();
910 } else if ( vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker) ) {
911 int aVtkId = picker->GetPointId();
912 if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) {
913 if ( SActor && SActor->hasIO() ) {
914 int anObjId = SActor->GetNodeObjId(aVtkId);
916 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
917 if(IsSelected(IO,aSel)) {
918 // This IO is already in the selection
919 aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
922 this->HighlightProp( NULL );
923 aSel->ClearIObjects();
925 aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
926 aSel->AddIObject( IO, false );
931 this->HighlightProp( NULL );
932 aSel->ClearIObjects();
935 if ( SActor && SActor->hasIO() ) {
937 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
938 if(IsSelected(IO,aSel)) {
939 // This IO is already in the selection
941 aSel->RemoveIObject(IO);
946 this->HighlightProp( NULL );
947 aSel->ClearIObjects();
949 aSel->AddIObject( IO, false );
952 // No selection clear all
953 this->PropPicked = 0;
954 this->HighlightProp( NULL );
955 aSel->ClearIObjects();
958 m_Interactor->EndPickCallback();
960 //processing rectangle selection
961 QString aComponentDataType = SUIT_Application::getDesktop()->getComponentDataType();
962 if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return;
963 m_Interactor->StartPickCallback();
966 this->PropPicked = 0;
967 this->HighlightProp( NULL );
968 aSel->ClearIObjects();
972 // vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
973 QRect rect(myPoint, myOtherPoint);
974 rect = rect.normalize();
976 m_Interactor->GetSize(w, h);
979 y1 = h - rect.top() - 1;
981 y2 = h - rect.bottom() - 1;
983 switch (aSelectionMode) {
984 case NodeSelection: {
985 if ( vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(m_Interactor->GetPicker()) ) {
986 vtkActorCollection* aListActors = this->CurrentRenderer->GetActors();
987 aListActors->InitTraversal();
988 while (vtkActor* aActor = aListActors->GetNextActor()) {
989 if (!aActor->GetVisibility())
991 if(SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor)) {
992 if (SActor->hasIO()) {
993 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
996 if (aSelActiveCompOnly && aComponentDataType != IO->getComponentDataType())
998 if (vtkDataSet* aDataSet = SActor->GetInput()) {
999 SALOME_Selection::TContainerOfId anIndices;
1000 for(int i = 0; i < aDataSet->GetNumberOfPoints(); i++) {
1002 aDataSet->GetPoint(i,aPoint);
1003 if (IsInRect(aPoint,x1,y1,x2,y2)){
1005 ComputeWorldToDisplay(aPoint[0],aPoint[1],aPoint[2],aDisp);
1006 if(aPointPicker->Pick(aDisp[0],aDisp[1],0.0,CurrentRenderer)){
1007 if(vtkActorCollection *anActorCollection = aPointPicker->GetActors()){
1008 if(anActorCollection->IsItemPresent(SActor)){
1009 float aPickedPoint[3];
1010 aPointPicker->GetMapperPosition(aPickedPoint);
1011 vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint);
1012 if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ){
1013 int anObjId = SActor->GetNodeObjId(aVtkId);
1014 anIndices.insert(anObjId);
1021 if (!anIndices.empty()) {
1022 aSel->AddOrRemoveIndex(IO, anIndices, true, false);
1023 aSel->AddIObject(IO, false);
1026 aSel->RemoveIObject(IO, false);
1036 case EdgeOfCellSelection:
1039 case VolumeSelection:
1041 vtkSmartPointer<VTKViewer_CellAreaPicker> picker = VTKViewer_CellRectPicker::New();
1042 picker->SetTolerance(0.001);
1043 picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
1045 vtkActorCollection* aListActors = picker->GetActors();
1046 aListActors->InitTraversal();
1047 while(vtkActor* aActor = aListActors->GetNextActor()) {
1048 if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
1049 if (aSActor->hasIO()) {
1050 Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
1051 if (aSelActiveCompOnly && aComponentDataType != aIO->getComponentDataType())
1053 VTKViewer_CellDataSet cellList = picker->GetCellData(aActor);
1054 if ( !cellList.empty() ) {
1055 SALOME_Selection::TContainerOfId anIndexes;
1056 VTKViewer_CellDataSet::iterator it;
1057 for ( it = cellList.begin(); it != cellList.end(); ++it ) {
1058 int aCellId = (*it).cellId;
1060 if ( !IsValid( aSActor, aCellId ) )
1063 int anObjId = aSActor->GetElemObjId(aCellId);
1065 if ( CheckDimensionId(aSelectionMode,aSActor,anObjId) ) {
1066 anIndexes.insert(anObjId);
1070 aSel->AddOrRemoveIndex(aIO, anIndexes, true, false);
1071 aSel->AddIObject(aIO, false);
1078 case ActorSelection: // objects selection
1080 vtkSmartPointer<VTKViewer_AreaPicker> picker = VTKViewer_AreaPicker::New();
1081 picker->SetTolerance(0.001);
1082 picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
1084 vtkActorCollection* aListActors = picker->GetActors();
1085 SALOME_ListIO aListIO;
1086 aListActors->InitTraversal();
1087 while(vtkActor* aActor = aListActors->GetNextActor()) {
1088 if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
1089 if (aSActor->hasIO()) {
1090 Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
1091 if (!IsStored(aIO,aListIO))
1092 aListIO.Append(aIO);
1096 if (!aListIO.IsEmpty()) {
1097 SALOME_ListIteratorOfListIO It(aListIO);
1098 for(;It.More();It.Next()) {
1099 Handle(SALOME_InteractiveObject) IOS = It.Value();
1101 aSel->AddIObject( IOS, false );
1106 m_Interactor->EndPickCallback();
1108 aActiveStudy->update3dViewers();
1112 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
1113 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
1114 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
1115 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
1117 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
1120 m_Interactor->GetSize(w, h);
1122 y = h - myPoint.y() - 1;
1127 if (myGUIWindow) myGUIWindow->update();
1131 /*! called during viewer operation when user moves mouse (!put necessary processing here!)*/
1132 void VTKViewer_InteractorStyle::onOperation(QPoint mousePos)
1134 if (!myGUIWindow) return;
1136 GetInteractor()->GetSize(w, h);
1138 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
1140 // processing panning
1141 //this->FindPokedCamera(mousePos.x(), mousePos.y());
1142 this->PanXY(mousePos.x(), myPoint.y(), myPoint.x(), mousePos.y());
1146 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
1148 // processing zooming
1149 //this->FindPokedCamera(mousePos.x(), mousePos.y());
1150 this->DollyXY(mousePos.x() - myPoint.x(), mousePos.y() - myPoint.y());
1154 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
1156 // processing rotation
1157 //this->FindPokedCamera(mousePos.x(), mousePos.y());
1158 this->RotateXY(mousePos.x() - myPoint.x(), myPoint.y() - mousePos.y());
1162 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
1164 // processing spinning
1165 //this->FindPokedCamera(mousePos.x(), mousePos.y());
1166 this->SpinXY(mousePos.x(), mousePos.y(), myPoint.x(), myPoint.y());
1170 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
1174 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
1177 setCursor(VTK_INTERACTOR_STYLE_CAMERA_SELECT);
1179 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
1181 myOtherPoint = mousePos;
1186 this->LastPos[0] = mousePos.x();
1187 this->LastPos[1] = h - mousePos.y() - 1;
1190 /*! called when selection mode changed (!put necessary initialization here!)*/
1191 void VTKViewer_InteractorStyle::OnSelectionModeChanged()
1194 myPreSelectionActor->SetVisibility(false);
1195 myElemId = myEdgeId = myNodeId = -1;
1196 mySelectedActor = NULL;
1199 /*! called when user moves mouse inside viewer window and there is no active viewer operation \n
1200 * (!put necessary processing here!)
1202 void VTKViewer_InteractorStyle::onCursorMove(QPoint mousePos) {
1203 // processing highlighting
1204 // SUIT_Study* anActiveStudy = SUIT_Application::getDesktop()->getActiveStudy();
1205 // SALOME_Selection* Sel = SALOME_Selection::Selection( anActiveStudy->getSelection() );
1206 // Selection_Mode aSelectionMode = Sel->SelectionMode();
1209 m_Interactor->GetSize(w, h);
1210 x = mousePos.x(); y = h - mousePos.y() - 1;
1212 this->FindPokedRenderer(x,y);
1213 m_Interactor->StartPickCallback();
1214 myPreSelectionActor->SetVisibility(false);
1216 vtkPicker* aPicker = vtkPicker::SafeDownCast(m_Interactor->GetPicker());
1217 aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
1219 SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
1221 if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
1222 int aVtkId = picker->GetCellId();
1223 if ( aVtkId >= 0 ) {
1224 int anObjId = SActor->GetElemObjId(aVtkId);
1225 if ( SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) {
1226 bool anIsSameObjId = (mySelectedActor == SActor && myElemId == anObjId);
1227 bool aResult = anIsSameObjId;
1228 if(!anIsSameObjId) {
1229 if(aSelectionMode != EdgeOfCellSelection) {
1230 aResult = CheckDimensionId(aSelectionMode,SActor,anObjId);
1232 mySelectedActor = SActor;
1234 m_Interactor->setCellData(anObjId,SActor,myPreSelectionActor);
1238 if(aSelectionMode == EdgeOfCellSelection){
1239 int anEdgeId = GetEdgeId(picker,SActor,anObjId);
1240 bool anIsSameEdgeId = (myEdgeId != anEdgeId) && anIsSameObjId;
1241 aResult = anIsSameEdgeId;
1242 if(!anIsSameEdgeId) {
1243 aResult = (anEdgeId >= 0);
1245 mySelectedActor = SActor;
1246 myEdgeId = anEdgeId;
1248 m_Interactor->setEdgeData(anObjId,SActor,-anEdgeId-1,myPreSelectionActor);
1253 myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
1254 myPreSelectionActor->SetVisibility(true);
1259 else if (vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker)) {
1260 int aVtkId = picker->GetPointId();
1261 if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) {
1262 if ( SActor && SActor->hasIO() ) {
1263 int anObjId = SActor->GetNodeObjId(aVtkId);
1264 bool anIsSameObjId = (mySelectedActor == SActor && myNodeId == anObjId);
1265 if(!anIsSameObjId) {
1266 mySelectedActor = SActor;
1268 m_Interactor->setPointData(anObjId,SActor,myPreSelectionActor);
1270 myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
1271 myPreSelectionActor->SetVisibility(true);
1275 else if ( vtkPicker::SafeDownCast(aPicker) ) {
1277 if ( myPreViewActor != SActor ) {
1278 if ( myPreViewActor != NULL ) {
1279 myPreViewActor->SetPreSelected( false );
1281 myPreViewActor = SActor;
1283 if ( SActor->hasIO() ) {
1284 Handle( SALOME_InteractiveObject) IO = SActor->getIO();
1285 if ( !IsSelected(IO,Sel) ) {
1286 // Find All actors with same IO
1287 vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
1288 theActors->InitTraversal();
1289 while( vtkActor *ac = theActors->GetNextActor() ) {
1290 if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
1291 if ( anActor->hasIO() ) {
1292 Handle(SALOME_InteractiveObject) IOS = anActor->getIO();
1293 if(IO->isSame(IOS)) {
1294 anActor->SetPreSelected( true );
1303 myPreViewActor = NULL;
1304 vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
1305 theActors->InitTraversal();
1306 while( vtkActor *ac = theActors->GetNextActor() ) {
1307 if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
1308 anActor->SetPreSelected( false );
1313 m_Interactor->EndPickCallback();
1314 //m_Interactor->Render();
1315 myGUIWindow->update();
1317 this->LastPos[0] = x;
1318 this->LastPos[1] = y;*/
1321 /*! called on finsh GlobalPan operation */
1322 void VTKViewer_InteractorStyle::Place(const int theX, const int theY)
1324 if (this->CurrentRenderer == NULL) {
1329 int *aSize = this->CurrentRenderer->GetRenderWindow()->GetSize();
1330 int centerX = aSize[0]/2;
1331 int centerY = aSize[1]/2;
1333 TranslateView(centerX, centerY, theX, theY);
1335 // restore zoom scale
1336 vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
1337 cam->SetParallelScale(myScale);
1338 ::ResetCameraClippingRange(this->CurrentRenderer);
1340 if (myGUIWindow) myGUIWindow->update();
1346 /*! Translates view from Point to Point*/
1347 void VTKViewer_InteractorStyle::TranslateView(int toX, int toY, int fromX, int fromY)
1349 vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
1350 double viewFocus[4], focalDepth, viewPoint[3];
1351 double newPickPoint[4], oldPickPoint[4], motionVector[3];
1352 cam->GetFocalPoint(viewFocus);
1354 this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1],
1355 viewFocus[2], viewFocus);
1356 focalDepth = viewFocus[2];
1358 this->ComputeDisplayToWorld(double(toX), double(toY),
1359 focalDepth, newPickPoint);
1360 this->ComputeDisplayToWorld(double(fromX),double(fromY),
1361 focalDepth, oldPickPoint);
1363 // camera motion is reversed
1364 motionVector[0] = oldPickPoint[0] - newPickPoint[0];
1365 motionVector[1] = oldPickPoint[1] - newPickPoint[1];
1366 motionVector[2] = oldPickPoint[2] - newPickPoint[2];
1368 cam->GetFocalPoint(viewFocus);
1369 cam->GetPosition(viewPoint);
1370 cam->SetFocalPoint(motionVector[0] + viewFocus[0],
1371 motionVector[1] + viewFocus[1],
1372 motionVector[2] + viewFocus[2]);
1373 cam->SetPosition(motionVector[0] + viewPoint[0],
1374 motionVector[1] + viewPoint[1],
1375 motionVector[2] + viewPoint[2]);
1379 /*! Checks: is the given Actor within display coordinates?*/
1380 bool VTKViewer_InteractorStyle::IsInRect(vtkActor* theActor,
1381 const int left, const int top,
1382 const int right, const int bottom)
1384 double* aBounds = theActor->GetBounds();
1385 double aMin[3], aMax[3];
1386 ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
1387 ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
1388 if (aMin[0] > aMax[0]) {
1389 double aBuf = aMin[0];
1393 if (aMin[1] > aMax[1]) {
1394 double aBuf = aMin[1];
1399 return ((aMin[0]>left) && (aMax[0]<right) && (aMin[1]>bottom) && (aMax[1]<top));
1403 /*! Checks: is the given Cell within display coordinates?*/
1404 bool VTKViewer_InteractorStyle::IsInRect(vtkCell* theCell,
1405 const int left, const int top,
1406 const int right, const int bottom)
1408 double* aBounds = theCell->GetBounds();
1409 double aMin[3], aMax[3];
1410 ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
1411 ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
1412 if (aMin[0] > aMax[0]) {
1413 double aBuf = aMin[0];
1417 if (aMin[1] > aMax[1]) {
1418 double aBuf = aMin[1];
1423 return ((aMin[0]>left) && (aMax[0]<right) && (aMin[1]>bottom) && (aMax[1]<top));
1426 /*!Checks: is given point \a thePoint in rectangle*/
1427 bool VTKViewer_InteractorStyle::IsInRect(double* thePoint,
1428 const int left, const int top,
1429 const int right, const int bottom)
1432 ComputeWorldToDisplay(thePoint[0], thePoint[1], thePoint[2], aPnt);
1434 return ((aPnt[0]>left) && (aPnt[0]<right) && (aPnt[1]>bottom) && (aPnt[1]<top));
1437 /*!Set filter \a theFilter*/
1438 void VTKViewer_InteractorStyle::SetFilter( const Handle(VTKViewer_Filter)& theFilter )
1440 myFilters[ theFilter->GetId() ] = theFilter;
1443 /*!Checks: is filter present (with id \a theId)
1444 *\param theId - filter id.
1446 bool VTKViewer_InteractorStyle::IsFilterPresent( const int theId )
1448 return myFilters.find( theId ) != myFilters.end();
1451 /*!Remove filter with id \a theId.
1452 *\param theId - filter id.
1454 void VTKViewer_InteractorStyle::RemoveFilter( const int theId )
1456 if ( IsFilterPresent( theId ) )
1457 myFilters.erase( theId );
1460 /*!Checks: is valid cell(node) with id \a theId in actor \a theActor.
1461 *\param theActor - VTKViewer_Actor pointer.
1462 *\param theId - cell id.
1463 *\param theIsNode - boolean flag, if true - node, else - cell.
1465 bool VTKViewer_InteractorStyle::IsValid( VTKViewer_Actor* theActor,
1467 const bool theIsNode )
1469 std::map<int, Handle(VTKViewer_Filter)>::const_iterator anIter;
1470 for ( anIter = myFilters.begin(); anIter != myFilters.end(); ++anIter )
1472 const Handle(VTKViewer_Filter)& aFilter = anIter->second;
1473 if ( theIsNode == aFilter->IsNodeFilter() &&
1474 !aFilter->IsValid( theActor, theId ) )
1480 /*!Gets filter handle by filter id \a theId.*/
1481 Handle(VTKViewer_Filter) VTKViewer_InteractorStyle::GetFilter( const int theId )
1483 return IsFilterPresent( theId ) ? myFilters[ theId ] : Handle(VTKViewer_Filter)();
1487 *\param incrX - X coordinate increment.
1488 *\param incrY - Y coordinate increment.
1490 void VTKViewer_InteractorStyle::IncrementalPan( const int incrX, const int incrY )
1492 this->PanXY( incrX, incrY, 0, 0 );
1496 *\param incr - zoom increment.
1498 void VTKViewer_InteractorStyle::IncrementalZoom( const int incr )
1500 this->DollyXY( incr, incr );
1503 /*!Increment rotate.
1504 *\param incrX - X coordinate increment.
1505 *\param incrY - Y coordinate increment.
1507 void VTKViewer_InteractorStyle::IncrementalRotate( const int incrX, const int incrY )
1509 this->RotateXY( incrX, -incrY );