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_InteractorStyleSALOME.cxx
25 // Author : Christophe ATTANASIO
29 #include "VTKViewer_InteractorStyleSALOME.h"
31 #include "VTKViewer_RenderWindowInteractor.h"
32 #include "VTKViewer_RenderWindow.h"
33 #include "VTKViewer_ViewFrame.h"
35 #include "VTKViewer_Utilities.h"
36 #include "VTKViewer_RectPicker.h"
37 #include "VTKViewer_CellRectPicker.h"
39 #include "QAD_Config.h"
40 #include "QAD_Application.h"
41 #include "QAD_Desktop.h"
43 #include "SALOME_Actor.h"
44 #include "VTKViewer_Actor.h"
45 #include "SALOME_Selection.h"
46 #include "SALOME_ListIteratorOfListIO.hxx"
48 #include <vtkObjectFactory.h>
50 #include <vtkCommand.h>
51 #include <vtkCamera.h>
52 #include <vtkRenderer.h>
53 #include <vtkPicker.h>
54 #include <vtkPointPicker.h>
55 #include <vtkCellPicker.h>
57 #include <vtkMapper.h>
58 #include <vtkDataSet.h>
59 #include <vtkSmartPointer.h>
61 #include <qapplication.h>
62 //VRV: porting on Qt 3.0.5
63 #if QT_VERSION >= 0x030005
66 //VRV: porting on Qt 3.0.5
69 #include "utilities.h"
75 static int MYDEBUG = 0;
77 static int MYDEBUG = 0;
81 static bool IsStored(Handle(SALOME_InteractiveObject)& theIO,
82 const SALOME_ListIO& theListIO)
84 if (!theListIO.IsEmpty()){
85 SALOME_ListIteratorOfListIO anIter(theListIO);
86 for(; anIter.More(); anIter.Next()) {
87 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
88 if(theIO->isSame(anIO)) {
89 theIO = anIO; //Added by SRN, fix SAL1307
98 static bool IsSelected(Handle(SALOME_InteractiveObject)& theIO,
99 SALOME_Selection* theSel)
101 return IsStored(theIO,theSel->StoredIObjects());
105 static int GetEdgeId(vtkPicker *thePicker, SALOME_Actor *theActor, int theObjId){
107 if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) {
108 float aPickPosition[3];
109 thePicker->GetPickPosition(aPickPosition);
110 float aMinDist = 1000000.0, aDist = 0;
111 for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
112 if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){
113 int subId; float pcoords[3], closestPoint[3], weights[3];
114 aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
115 if (aDist < aMinDist) {
126 static bool CheckDimensionId(Selection_Mode theMode, SALOME_Actor *theActor, vtkIdType theObjId){
131 return ( theActor->GetObjDimension( theObjId ) == 1 );
133 return ( theActor->GetObjDimension( theObjId ) == 2 );
134 case VolumeSelection:
135 return ( theActor->GetObjDimension( theObjId ) == 3 );
141 //----------------------------------------------------------------------------
142 vtkStandardNewMacro(VTKViewer_InteractorStyleSALOME);
143 //----------------------------------------------------------------------------
145 VTKViewer_InteractorStyleSALOME::VTKViewer_InteractorStyleSALOME()
147 this->MotionFactor = 10.0;
148 this->State = VTK_INTERACTOR_STYLE_CAMERA_NONE;
149 this->RadianToDegree = 180.0 / vtkMath::Pi();
150 this->ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE;
153 myPreSelectionActor = VTKViewer_Actor::New();
154 myPreSelectionActor->GetProperty()->SetColor(0,1,1);
155 myPreSelectionActor->GetProperty()->SetLineWidth(5);
156 myPreSelectionActor->GetProperty()->SetPointSize(5);
158 OnSelectionModeChanged();
161 //----------------------------------------------------------------------------
162 VTKViewer_InteractorStyleSALOME::~VTKViewer_InteractorStyleSALOME()
164 if(MYDEBUG) INFOS("VTKViewer_InteractorStyleSALOME::~VTKViewer_InteractorStyleSALOME()");
165 m_ViewFrame->RemoveActor(myPreSelectionActor);
168 //----------------------------------------------------------------------------
169 void VTKViewer_InteractorStyleSALOME::setPreselectionProp(const double& theRed, const double& theGreen,
170 const double& theBlue, const int& theWidth)
172 if ( myPreSelectionActor->GetProperty() == 0 )
174 myPreSelectionActor->GetProperty()->SetColor(theRed, theGreen, theBlue);
175 myPreSelectionActor->GetProperty()->SetLineWidth(theWidth);
176 myPreSelectionActor->GetProperty()->SetPointSize(theWidth);
179 //----------------------------------------------------------------------------
180 void VTKViewer_InteractorStyleSALOME::SetInteractor(vtkRenderWindowInteractor *theInteractor){
181 m_Interactor = dynamic_cast<VTKViewer_RenderWindowInteractor*>(theInteractor);
182 Superclass::SetInteractor(theInteractor);
185 //----------------------------------------------------------------------------
186 void VTKViewer_InteractorStyleSALOME::setViewFrame(VTKViewer_ViewFrame* theViewFrame){
187 m_ViewFrame = theViewFrame;
188 m_ViewFrame->AddActor(myPreSelectionActor);
189 myPreSelectionActor->Delete();
192 //----------------------------------------------------------------------------
193 void VTKViewer_InteractorStyleSALOME::setGUIWindow(QWidget* theWindow){
194 myGUIWindow = theWindow;
197 //----------------------------------------------------------------------------
198 void VTKViewer_InteractorStyleSALOME::RotateXY(int dx, int dy)
204 if (this->CurrentRenderer == NULL)
209 int *size = this->CurrentRenderer->GetRenderWindow()->GetSize();
210 this->DeltaElevation = -20.0 / size[1];
211 this->DeltaAzimuth = -20.0 / size[0];
213 rxf = (double)dx * this->DeltaAzimuth * this->MotionFactor;
214 ryf = (double)dy * this->DeltaElevation * this->MotionFactor;
216 cam = this->CurrentRenderer->GetActiveCamera();
219 cam->OrthogonalizeViewUp();
220 ::ResetCameraClippingRange(this->CurrentRenderer);
221 //this->Interactor->Render();
222 myGUIWindow->update();
225 //----------------------------------------------------------------------------
226 void VTKViewer_InteractorStyleSALOME::PanXY(int x, int y, int oldX, int oldY)
228 TranslateView(x, y, oldX, oldY);
229 //this->Interactor->Render();
230 myGUIWindow->update();
234 //----------------------------------------------------------------------------
235 void VTKViewer_InteractorStyleSALOME::DollyXY(int dx, int dy)
237 if (this->CurrentRenderer == NULL) return;
239 double dxf = this->MotionFactor * (double)(dx) / (double)(this->CurrentRenderer->GetCenter()[1]);
240 double dyf = this->MotionFactor * (double)(dy) / (double)(this->CurrentRenderer->GetCenter()[1]);
242 double zoomFactor = pow((double)1.1, dxf + dyf);
244 vtkCamera *aCam = this->CurrentRenderer->GetActiveCamera();
245 if (aCam->GetParallelProjection())
246 aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor);
248 aCam->Dolly(zoomFactor);
249 ::ResetCameraClippingRange(this->CurrentRenderer);
252 //this->Interactor->Render();
253 myGUIWindow->update();
256 //----------------------------------------------------------------------------
257 void VTKViewer_InteractorStyleSALOME::SpinXY(int x, int y, int oldX, int oldY)
261 if (this->CurrentRenderer == NULL)
266 double newAngle = atan2((double)(y - this->CurrentRenderer->GetCenter()[1]),
267 (double)(x - this->CurrentRenderer->GetCenter()[0]));
268 double oldAngle = atan2((double)(oldY -this->CurrentRenderer->GetCenter()[1]),
269 (double)(oldX - this->CurrentRenderer->GetCenter()[0]));
271 newAngle *= this->RadianToDegree;
272 oldAngle *= this->RadianToDegree;
274 cam = this->CurrentRenderer->GetActiveCamera();
275 cam->Roll(newAngle - oldAngle);
276 cam->OrthogonalizeViewUp();
278 //this->Interactor->Render();
279 myGUIWindow->update();
283 //----------------------------------------------------------------------------
284 void VTKViewer_InteractorStyleSALOME::OnMouseMove(int vtkNotUsed(ctrl),
288 myShiftState = shift;
289 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
290 onOperation(QPoint(x, y));
291 else if (ForcedState == VTK_INTERACTOR_STYLE_CAMERA_NONE)
292 onCursorMove(QPoint(x, y));
296 //----------------------------------------------------------------------------
297 void VTKViewer_InteractorStyleSALOME::OnLeftButtonDown(int ctrl, int shift,
300 if (this->HasObserver(vtkCommand::LeftButtonPressEvent)) {
301 this->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL);
304 this->FindPokedRenderer(x, y);
305 if (this->CurrentRenderer == NULL) {
308 myShiftState = shift;
309 // finishing current viewer operation
310 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
312 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
314 myOtherPoint = myPoint = QPoint(x, y);
315 if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
316 startOperation(ForcedState);
319 startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
321 startOperation(VTK_INTERACTOR_STYLE_CAMERA_SELECT);
327 //----------------------------------------------------------------------------
328 void VTKViewer_InteractorStyleSALOME::OnLeftButtonUp(int vtkNotUsed(ctrl),
333 myShiftState = shift;
334 // finishing current viewer operation
335 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
337 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
342 //----------------------------------------------------------------------------
343 void VTKViewer_InteractorStyleSALOME::OnMiddleButtonDown(int ctrl,
347 if (this->HasObserver(vtkCommand::MiddleButtonPressEvent))
349 this->InvokeEvent(vtkCommand::MiddleButtonPressEvent,NULL);
352 this->FindPokedRenderer(x, y);
353 if (this->CurrentRenderer == NULL)
357 myShiftState = shift;
358 // finishing current viewer operation
359 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
361 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
363 myOtherPoint = myPoint = QPoint(x, y);
364 if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
365 startOperation(ForcedState);
369 startOperation(VTK_INTERACTOR_STYLE_CAMERA_PAN);
374 //----------------------------------------------------------------------------
375 void VTKViewer_InteractorStyleSALOME::OnMiddleButtonUp(int vtkNotUsed(ctrl),
380 myShiftState = shift;
381 // finishing current viewer operation
382 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
384 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
389 //----------------------------------------------------------------------------
390 void VTKViewer_InteractorStyleSALOME::OnRightButtonDown(int ctrl,
394 if (this->HasObserver(vtkCommand::RightButtonPressEvent))
396 this->InvokeEvent(vtkCommand::RightButtonPressEvent,NULL);
399 this->FindPokedRenderer(x, y);
400 if (this->CurrentRenderer == NULL)
404 myShiftState = shift;
405 // finishing current viewer operation
406 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
408 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
410 myOtherPoint = myPoint = QPoint(x, y);
411 if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
412 startOperation(ForcedState);
416 startOperation(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
420 //----------------------------------------------------------------------------
421 void VTKViewer_InteractorStyleSALOME::OnRightButtonUp(int vtkNotUsed(ctrl),
426 myShiftState = shift;
427 // finishing current viewer operation
428 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
430 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
434 //----------------------------------------------------------------------------
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 const char* imageRotateCursor[] = {
479 "................................",
480 "................................",
481 "................................",
482 "................................",
483 "........#.......................",
484 ".......#.a......................",
485 "......#######...................",
486 ".......#aaaaa#####..............",
487 "........#..##.a#aa##........##..",
488 ".........a#.aa..#..a#.....##.aa.",
489 ".........#.a.....#...#..##.aa...",
490 ".........#a.......#..###.aa.....",
491 "........#.a.......#a..#aa.......",
492 "........#a.........#..#a........",
493 "........#a.........#a.#a........",
494 "........#a.........#a.#a........",
495 "........#a.........#a.#a........",
496 ".........#.........#a#.a........",
497 "........##a........#a#a.........",
498 "......##.a#.......#.#.a.........",
499 "....##.aa..##.....##.a..........",
500 "..##.aa.....a#####.aa...........",
501 "...aa.........aaa#a.............",
502 "................#.a.............",
503 "...............#.a..............",
504 "..............#.a...............",
505 "...............a................",
506 "................................",
507 "................................",
508 "................................",
509 "................................",
510 "................................"};
513 //----------------------------------------------------------------------------
514 // loads cursors for viewer operations - zoom, pan, etc...
515 void VTKViewer_InteractorStyleSALOME::loadCursors()
517 myDefCursor = QCursor(ArrowCursor);
518 myHandCursor = QCursor(PointingHandCursor);
519 myPanCursor = QCursor(SizeAllCursor);
520 myZoomCursor = QCursor(QPixmap(imageZoomCursor));
521 myRotateCursor = QCursor(QPixmap(imageRotateCursor));
522 mySpinCursor = QCursor(QPixmap(imageRotateCursor)); // temporarly !!!!!!
523 myGlobalPanCursor = QCursor(CrossCursor);
524 myCursorState = false;
528 //----------------------------------------------------------------------------
529 // event filter - controls mouse and keyboard events during viewer operations
530 bool VTKViewer_InteractorStyleSALOME::eventFilter(QObject* object, QEvent* event)
532 if (!myGUIWindow) return false;
533 if ( (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::KeyPress) && object != myGUIWindow)
535 qApp->removeEventFilter(this);
536 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
538 return QObject::eventFilter(object, event);
542 //----------------------------------------------------------------------------
543 // starts Zoom operation (e.g. through menu command)
544 void VTKViewer_InteractorStyleSALOME::startZoom()
546 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
549 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
551 setCursor(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
552 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ZOOM;
553 qApp->installEventFilter(this);
557 //----------------------------------------------------------------------------
558 // starts Pan operation (e.g. through menu command)
559 void VTKViewer_InteractorStyleSALOME::startPan()
561 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
564 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
566 setCursor(VTK_INTERACTOR_STYLE_CAMERA_PAN);
567 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_PAN;
568 qApp->installEventFilter(this);
571 //----------------------------------------------------------------------------
572 // starts Rotate operation (e.g. through menu command)
573 void VTKViewer_InteractorStyleSALOME::startRotate()
575 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
578 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
580 setCursor(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
581 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ROTATE;
582 qApp->installEventFilter(this);
586 //----------------------------------------------------------------------------
587 // starts Spin operation (e.g. through menu command)
588 void VTKViewer_InteractorStyleSALOME::startSpin()
590 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
593 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
595 setCursor(VTK_INTERACTOR_STYLE_CAMERA_SPIN);
596 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_SPIN;
597 qApp->installEventFilter(this);
602 //----------------------------------------------------------------------------
603 // starts Fit Area operation (e.g. through menu command)
604 void VTKViewer_InteractorStyleSALOME::startFitArea()
606 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
609 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
611 setCursor(VTK_INTERACTOR_STYLE_CAMERA_FIT);
612 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_FIT;
613 qApp->installEventFilter(this);
617 //----------------------------------------------------------------------------
618 // starts Global Panning operation (e.g. through menu command)
619 void VTKViewer_InteractorStyleSALOME::startGlobalPan()
621 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
624 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
626 setCursor(VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN);
627 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN;
629 // store current zoom scale
630 vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
631 myScale = cam->GetParallelScale();
633 if (m_ViewFrame) m_ViewFrame->onViewFitAll();
635 if (myGUIWindow) myGUIWindow->update();
637 qApp->installEventFilter(this);
641 //----------------------------------------------------------------------------
642 // returns TRUE if needs redrawing
643 bool VTKViewer_InteractorStyleSALOME::needsRedrawing()
645 return State == VTK_INTERACTOR_STYLE_CAMERA_ZOOM ||
646 State == VTK_INTERACTOR_STYLE_CAMERA_PAN ||
647 State == VTK_INTERACTOR_STYLE_CAMERA_ROTATE ||
648 State == VTK_INTERACTOR_STYLE_CAMERA_SPIN ||
649 State == VTK_INTERACTOR_STYLE_CAMERA_NONE;
653 //----------------------------------------------------------------------------
654 // fits viewer contents to rect
655 void VTKViewer_InteractorStyleSALOME::fitRect(const int left,
660 if (this->CurrentRenderer == NULL) return;
663 int x = (left + right)/2;
664 int y = (top + bottom)/2;
665 int *aSize = this->CurrentRenderer->GetRenderWindow()->GetSize();
666 int oldX = aSize[0]/2;
667 int oldY = aSize[1]/2;
668 TranslateView(oldX, oldY, x, y);
671 double dxf = (double)(aSize[0]) / (double)(abs(right - left));
672 double dyf = (double)(aSize[1]) / (double)(abs(bottom - top));
673 double zoomFactor = (dxf + dyf)/2 ;
675 vtkCamera *aCam = this->CurrentRenderer->GetActiveCamera();
676 if(aCam->GetParallelProjection())
677 aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor);
679 aCam->Dolly(zoomFactor);
680 ::ResetCameraClippingRange(this->CurrentRenderer);
683 myGUIWindow->update();
687 //----------------------------------------------------------------------------
688 // starts viewer operation (!internal usage!)
689 void VTKViewer_InteractorStyleSALOME::startOperation(int operation)
693 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
694 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
695 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
696 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
697 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
698 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
699 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
700 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
701 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
703 if (State != VTK_INTERACTOR_STYLE_CAMERA_SELECT)
704 setCursor(operation);
707 case VTK_INTERACTOR_STYLE_CAMERA_NONE:
709 setCursor(VTK_INTERACTOR_STYLE_CAMERA_NONE);
710 State = ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE;
716 //----------------------------------------------------------------------------
717 // sets proper cursor for window when viewer operation is activated
718 void VTKViewer_InteractorStyleSALOME::setCursor(const int operation)
720 if (!myGUIWindow) return;
723 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
724 myGUIWindow->setCursor(myZoomCursor);
725 myCursorState = true;
727 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
728 myGUIWindow->setCursor(myPanCursor);
729 myCursorState = true;
731 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
732 myGUIWindow->setCursor(myRotateCursor);
733 myCursorState = true;
735 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
736 myGUIWindow->setCursor(mySpinCursor);
737 myCursorState = true;
739 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
740 myGUIWindow->setCursor(myGlobalPanCursor);
741 myCursorState = true;
743 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
744 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
745 myGUIWindow->setCursor(myHandCursor);
746 myCursorState = true;
748 case VTK_INTERACTOR_STYLE_CAMERA_NONE:
750 myGUIWindow->setCursor(myDefCursor);
751 myCursorState = false;
757 //----------------------------------------------------------------------------
758 // called when viewer operation started (!put necessary initialization here!)
759 void VTKViewer_InteractorStyleSALOME::onStartOperation()
761 if (!myGUIWindow) return;
762 // VSV: LOD actor activisation
763 // this->Interactor->GetRenderWindow()->SetDesiredUpdateRate(this->Interactor->GetDesiredUpdateRate());
765 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
766 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
768 QPainter p(myGUIWindow);
769 p.setPen(Qt::lightGray);
770 p.setRasterOp(Qt::XorROP);
771 p.drawRect(QRect(myPoint, myOtherPoint));
774 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
775 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
776 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
777 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
778 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
784 //----------------------------------------------------------------------------
785 // called when viewer operation finished (!put necessary post-processing here!)
786 void VTKViewer_InteractorStyleSALOME::onFinishOperation()
788 if (!myGUIWindow) return;
791 QAD_Study* aActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
792 SALOME_Selection* aSel = SALOME_Selection::Selection( aActiveStudy->getSelection() );
794 // VSV: LOD actor activisation
795 // rwi->GetRenderWindow()->SetDesiredUpdateRate(rwi->GetStillUpdateRate());
797 Selection_Mode aSelectionMode = aSel->SelectionMode();
798 bool aSelActiveCompOnly = aSel->IsSelectActiveCompOnly();
801 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
802 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
804 QPainter p(myGUIWindow);
805 p.setPen(Qt::lightGray);
806 p.setRasterOp(Qt::XorROP);
807 QRect rect(myPoint, myOtherPoint);
809 rect = rect.normalize();
810 if (State == VTK_INTERACTOR_STYLE_CAMERA_FIT) {
811 // making fit rect opeation
813 m_Interactor->GetSize(w, h);
816 y1 = h - rect.top() - 1;
818 y2 = h - rect.bottom() - 1;
819 fitRect(x1, y1, x2, y2);
822 if (myPoint == myOtherPoint) {
823 // process point selection
825 m_Interactor->GetSize(w, h);
827 y = h - myPoint.y() - 1;
829 this->FindPokedRenderer(x, y);
830 m_Interactor->StartPickCallback();
832 vtkPicker* aPicker = vtkPicker::SafeDownCast(m_Interactor->GetPicker());
833 aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
835 SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
837 if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
838 int aVtkId = picker->GetCellId();
839 if ( aVtkId >= 0 && SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) {
840 int anObjId = SActor->GetElemObjId(aVtkId);
842 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
843 if(aSelectionMode != EdgeOfCellSelection) {
844 if(CheckDimensionId(aSelectionMode,SActor,anObjId)){
845 if(MYDEBUG) INFOS(" CellId : "<<anObjId);
846 if (IsSelected(IO,aSel)) {
847 // This IO is already in the selection
848 aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
851 this->HighlightProp( NULL );
852 aSel->ClearIObjects();
854 aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
855 aSel->AddIObject( IO, false );
860 this->HighlightProp( NULL );
861 aSel->ClearIObjects();
863 int anEdgeId = GetEdgeId(picker,SActor,anObjId);
865 if(MYDEBUG) INFOS(" CellId : "<<anObjId<<"; EdgeId : "<<anEdgeId);
866 aSel->AddOrRemoveIndex( IO, anObjId, true, false);
867 aSel->AddOrRemoveIndex( IO, -anEdgeId-1, true, true );
868 aSel->AddIObject( IO, false );
873 this->HighlightProp( NULL );
874 aSel->ClearIObjects();
876 } else if ( vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker) ) {
877 int aVtkId = picker->GetPointId();
878 if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) {
879 if ( SActor && SActor->hasIO() ) {
880 int anObjId = SActor->GetNodeObjId(aVtkId);
882 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
883 if(IsSelected(IO,aSel)) {
884 // This IO is already in the selection
885 aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
888 this->HighlightProp( NULL );
889 aSel->ClearIObjects();
891 if(MYDEBUG) INFOS(" PointId : "<<anObjId);
892 aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
893 aSel->AddIObject( IO, false );
898 this->HighlightProp( NULL );
899 aSel->ClearIObjects();
902 if ( SActor && SActor->hasIO() ) {
904 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
905 if(IsSelected(IO,aSel)) {
906 // This IO is already in the selection
908 aSel->RemoveIObject(IO);
913 this->HighlightProp( NULL );
914 aSel->ClearIObjects();
916 aSel->AddIObject( IO, false );
919 // No selection clear all
920 this->PropPicked = 0;
921 this->HighlightProp( NULL );
922 aSel->ClearIObjects();
925 m_Interactor->EndPickCallback();
927 //processing rectangle selection
928 QString aComponentDataType = QAD_Application::getDesktop()->getComponentDataType();
929 if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return;
930 m_Interactor->StartPickCallback();
933 this->PropPicked = 0;
934 this->HighlightProp( NULL );
935 aSel->ClearIObjects();
939 // vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
940 QRect rect(myPoint, myOtherPoint);
941 rect = rect.normalize();
943 m_Interactor->GetSize(w, h);
946 y1 = h - rect.top() - 1;
948 y2 = h - rect.bottom() - 1;
950 switch (aSelectionMode) {
951 case NodeSelection: {
952 if ( vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(m_Interactor->GetPicker()) ) {
953 vtkActorCollection* aListActors = this->CurrentRenderer->GetActors();
954 aListActors->InitTraversal();
955 while (vtkActor* aActor = aListActors->GetNextActor()) {
956 if (!aActor->GetVisibility())
958 if(SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor)) {
959 if (SActor->hasIO()) {
960 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
963 if (aSelActiveCompOnly && aComponentDataType != IO->getComponentDataType())
965 if (vtkDataSet* aDataSet = SActor->GetInput()) {
966 SALOME_Selection::TContainerOfId anIndices;
967 for(int i = 0; i < aDataSet->GetNumberOfPoints(); i++) {
969 aDataSet->GetPoint(i,aPoint);
970 if (IsInRect(aPoint,x1,y1,x2,y2)){
972 ComputeWorldToDisplay(aPoint[0],aPoint[1],aPoint[2],aDisp);
973 if(aPointPicker->Pick(aDisp[0],aDisp[1],0.0,CurrentRenderer)){
974 if(vtkActorCollection *anActorCollection = aPointPicker->GetActors()){
975 if(anActorCollection->IsItemPresent(SActor)){
976 float aPickedPoint[3];
977 aPointPicker->GetMapperPosition(aPickedPoint);
978 vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint);
979 if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ){
980 int anObjId = SActor->GetNodeObjId(aVtkId);
981 anIndices.insert(anObjId);
988 if (!anIndices.empty()) {
989 aSel->AddOrRemoveIndex(IO, anIndices, true, false);
990 aSel->AddIObject(IO, false);
993 aSel->RemoveIObject(IO, false);
1003 case EdgeOfCellSelection:
1006 case VolumeSelection:
1008 vtkSmartPointer<VTKViewer_CellRectPicker> picker = VTKViewer_CellRectPicker::New();
1009 picker->SetTolerance(0.001);
1010 picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
1012 vtkActorCollection* aListActors = picker->GetActors();
1013 aListActors->InitTraversal();
1014 while(vtkActor* aActor = aListActors->GetNextActor()) {
1015 if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
1016 if (aSActor->hasIO()) {
1017 Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
1018 if (aSelActiveCompOnly && aComponentDataType != aIO->getComponentDataType())
1020 VTKViewer_CellDataSet cellList = picker->GetCellData(aActor);
1021 if ( !cellList.empty() ) {
1022 if(MYDEBUG) INFOS ( " NAME Actor : " << aSActor->getName() );
1023 SALOME_Selection::TContainerOfId anIndexes;
1024 VTKViewer_CellDataSet::iterator it;
1025 for ( it = cellList.begin(); it != cellList.end(); ++it ) {
1026 int aCellId = (*it).cellId;
1028 if ( !IsValid( aSActor, aCellId ) )
1031 int anObjId = aSActor->GetElemObjId(aCellId);
1033 if ( CheckDimensionId(aSelectionMode,aSActor,anObjId) ) {
1034 anIndexes.insert(anObjId);
1038 aSel->AddOrRemoveIndex(aIO, anIndexes, true, false);
1039 aSel->AddIObject(aIO, false);
1046 case ActorSelection: // objects selection
1048 vtkSmartPointer<VTKViewer_RectPicker> picker = VTKViewer_RectPicker::New();
1049 picker->SetTolerance(0.001);
1050 picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
1052 vtkActorCollection* aListActors = picker->GetActors();
1053 SALOME_ListIO aListIO;
1054 aListActors->InitTraversal();
1055 while(vtkActor* aActor = aListActors->GetNextActor()) {
1056 if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
1057 if (aSActor->hasIO()) {
1058 Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
1059 if (!IsStored(aIO,aListIO))
1060 aListIO.Append(aIO);
1064 if (!aListIO.IsEmpty()) {
1065 SALOME_ListIteratorOfListIO It(aListIO);
1066 for(;It.More();It.Next()) {
1067 Handle(SALOME_InteractiveObject) IOS = It.Value();
1069 aSel->AddIObject( IOS, false );
1074 m_Interactor->EndPickCallback();
1076 aActiveStudy->update3dViewers();
1080 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
1081 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
1082 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
1083 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
1085 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
1088 m_Interactor->GetSize(w, h);
1090 y = h - myPoint.y() - 1;
1095 if (myGUIWindow) myGUIWindow->update();
1099 // called during viewer operation when user moves mouse (!put necessary processing here!)
1100 void VTKViewer_InteractorStyleSALOME::onOperation(QPoint mousePos)
1102 if (!myGUIWindow) return;
1104 GetInteractor()->GetSize(w, h);
1106 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
1108 // processing panning
1109 //this->FindPokedCamera(mousePos.x(), mousePos.y());
1110 this->PanXY(mousePos.x(), myPoint.y(), myPoint.x(), mousePos.y());
1114 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
1116 // processing zooming
1117 //this->FindPokedCamera(mousePos.x(), mousePos.y());
1118 this->DollyXY(mousePos.x() - myPoint.x(), mousePos.y() - myPoint.y());
1122 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
1124 // processing rotation
1125 //this->FindPokedCamera(mousePos.x(), mousePos.y());
1126 this->RotateXY(mousePos.x() - myPoint.x(), myPoint.y() - mousePos.y());
1130 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
1132 // processing spinning
1133 //this->FindPokedCamera(mousePos.x(), mousePos.y());
1134 this->SpinXY(mousePos.x(), mousePos.y(), myPoint.x(), myPoint.y());
1138 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
1142 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
1145 setCursor(VTK_INTERACTOR_STYLE_CAMERA_SELECT);
1147 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
1149 QPainter p(myGUIWindow);
1150 p.setPen(Qt::lightGray);
1151 p.setRasterOp(Qt::XorROP);
1152 p.drawRect(QRect(myPoint, myOtherPoint));
1153 myOtherPoint = mousePos;
1154 p.drawRect(QRect(myPoint, myOtherPoint));
1158 this->LastPos[0] = mousePos.x();
1159 this->LastPos[1] = h - mousePos.y() - 1;
1162 // called when selection mode changed (!put necessary initialization here!)
1163 void VTKViewer_InteractorStyleSALOME::OnSelectionModeChanged()
1166 myPreSelectionActor->SetVisibility(false);
1167 myElemId = myEdgeId = myNodeId = -1;
1168 mySelectedActor = NULL;
1171 // called when user moves mouse inside viewer window and there is no active viewer operation
1172 // (!put necessary processing here!)
1173 void VTKViewer_InteractorStyleSALOME::onCursorMove(QPoint mousePos) {
1174 // processing highlighting
1175 QAD_Study* anActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
1176 SALOME_Selection* Sel = SALOME_Selection::Selection( anActiveStudy->getSelection() );
1177 Selection_Mode aSelectionMode = Sel->SelectionMode();
1180 m_Interactor->GetSize(w, h);
1181 x = mousePos.x(); y = h - mousePos.y() - 1;
1183 this->FindPokedRenderer(x,y);
1184 m_Interactor->StartPickCallback();
1185 myPreSelectionActor->SetVisibility(false);
1187 vtkPicker* aPicker = vtkPicker::SafeDownCast(m_Interactor->GetPicker());
1188 aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
1190 SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
1192 if (SActor && myPreSelectionActor){
1194 SActor->GetPosition(aPos);
1195 myPreSelectionActor->SetPosition(aPos);
1198 if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
1199 int aVtkId = picker->GetCellId();
1200 if ( aVtkId >= 0 ) {
1201 int anObjId = SActor->GetElemObjId(aVtkId);
1202 if ( SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) {
1203 bool anIsSameObjId = (mySelectedActor == SActor && myElemId == anObjId);
1204 bool aResult = anIsSameObjId;
1205 if(!anIsSameObjId) {
1206 if(aSelectionMode != EdgeOfCellSelection) {
1207 aResult = CheckDimensionId(aSelectionMode,SActor,anObjId);
1209 mySelectedActor = SActor;
1211 if(MYDEBUG) INFOS(" CellId : "<<anObjId);
1212 m_Interactor->setCellData(anObjId,SActor,myPreSelectionActor);
1216 if(aSelectionMode == EdgeOfCellSelection){
1217 int anEdgeId = GetEdgeId(picker,SActor,anObjId);
1218 bool anIsSameEdgeId = (myEdgeId != anEdgeId) && anIsSameObjId;
1219 aResult = anIsSameEdgeId;
1220 if(!anIsSameEdgeId) {
1221 aResult = (anEdgeId >= 0);
1223 mySelectedActor = SActor;
1224 myEdgeId = anEdgeId;
1226 if(MYDEBUG) INFOS(" CellId : "<<anObjId<<"; EdgeId : "<<anEdgeId);
1227 m_Interactor->setEdgeData(anObjId,SActor,-anEdgeId-1,myPreSelectionActor);
1232 myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
1233 myPreSelectionActor->SetVisibility(true);
1238 else if (vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker)) {
1239 int aVtkId = picker->GetPointId();
1240 if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) {
1241 if ( SActor && SActor->hasIO() ) {
1242 int anObjId = SActor->GetNodeObjId(aVtkId);
1243 bool anIsSameObjId = (mySelectedActor == SActor && myNodeId == anObjId);
1244 if(!anIsSameObjId) {
1245 mySelectedActor = SActor;
1247 if(MYDEBUG) INFOS(" PointId : "<<anObjId);
1248 m_Interactor->setPointData(anObjId,SActor,myPreSelectionActor);
1250 myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
1251 myPreSelectionActor->SetVisibility(true);
1255 else if ( vtkPicker::SafeDownCast(aPicker) ) {
1257 if ( myPreViewActor != SActor ) {
1258 if ( myPreViewActor != NULL ) {
1259 myPreViewActor->SetPreSelected( false );
1261 myPreViewActor = SActor;
1263 if ( SActor->hasIO() ) {
1264 Handle( SALOME_InteractiveObject) IO = SActor->getIO();
1265 if ( !IsSelected(IO,Sel) ) {
1266 // Find All actors with same IO
1267 vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
1268 theActors->InitTraversal();
1269 while( vtkActor *ac = theActors->GetNextActor() ) {
1270 if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
1271 if ( anActor->hasIO() ) {
1272 Handle(SALOME_InteractiveObject) IOS = anActor->getIO();
1273 if(IO->isSame(IOS)) {
1274 anActor->SetPreSelected( true );
1279 //if(MYDEBUG) INFOS ( " NAME PREVIEW " << SActor->getName() );
1284 myPreViewActor = NULL;
1285 vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
1286 theActors->InitTraversal();
1287 while( vtkActor *ac = theActors->GetNextActor() ) {
1288 if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
1289 anActor->SetPreSelected( false );
1294 m_Interactor->EndPickCallback();
1295 //m_Interactor->Render();
1296 myGUIWindow->update();
1298 this->LastPos[0] = x;
1299 this->LastPos[1] = y;
1302 // called on finsh GlobalPan operation
1303 void VTKViewer_InteractorStyleSALOME::Place(const int theX, const int theY)
1305 if (this->CurrentRenderer == NULL) {
1310 int *aSize = this->CurrentRenderer->GetRenderWindow()->GetSize();
1311 int centerX = aSize[0]/2;
1312 int centerY = aSize[1]/2;
1314 TranslateView(centerX, centerY, theX, theY);
1316 // restore zoom scale
1317 vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
1318 cam->SetParallelScale(myScale);
1319 ::ResetCameraClippingRange(this->CurrentRenderer);
1321 if (myGUIWindow) myGUIWindow->update();
1327 // Translates view from Point to Point
1328 void VTKViewer_InteractorStyleSALOME::TranslateView(int toX, int toY, int fromX, int fromY)
1330 vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
1331 double viewFocus[4], focalDepth, viewPoint[3];
1332 float newPickPoint[4], oldPickPoint[4], motionVector[3];
1333 cam->GetFocalPoint(viewFocus);
1335 this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1],
1336 viewFocus[2], viewFocus);
1337 focalDepth = viewFocus[2];
1339 this->ComputeDisplayToWorld(double(toX), double(toY),
1340 focalDepth, newPickPoint);
1341 this->ComputeDisplayToWorld(double(fromX),double(fromY),
1342 focalDepth, oldPickPoint);
1344 // camera motion is reversed
1345 motionVector[0] = oldPickPoint[0] - newPickPoint[0];
1346 motionVector[1] = oldPickPoint[1] - newPickPoint[1];
1347 motionVector[2] = oldPickPoint[2] - newPickPoint[2];
1349 cam->GetFocalPoint(viewFocus);
1350 cam->GetPosition(viewPoint);
1351 cam->SetFocalPoint(motionVector[0] + viewFocus[0],
1352 motionVector[1] + viewFocus[1],
1353 motionVector[2] + viewFocus[2]);
1354 cam->SetPosition(motionVector[0] + viewPoint[0],
1355 motionVector[1] + viewPoint[1],
1356 motionVector[2] + viewPoint[2]);
1360 /// Checks: is the given Actor within display coordinates?
1361 bool VTKViewer_InteractorStyleSALOME::IsInRect(vtkActor* theActor,
1362 const int left, const int top,
1363 const int right, const int bottom)
1365 float* aBounds = theActor->GetBounds();
1366 float aMin[3], aMax[3];
1367 ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
1368 ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
1369 if (aMin[0] > aMax[0]) {
1370 float aBuf = aMin[0];
1374 if (aMin[1] > aMax[1]) {
1375 float aBuf = aMin[1];
1380 return ((aMin[0]>left) && (aMax[0]<right) && (aMin[1]>bottom) && (aMax[1]<top));
1384 /// Checks: is the given Cell within display coordinates?
1385 bool VTKViewer_InteractorStyleSALOME::IsInRect(vtkCell* theCell,
1386 const int left, const int top,
1387 const int right, const int bottom)
1389 float* aBounds = theCell->GetBounds();
1390 float aMin[3], aMax[3];
1391 ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
1392 ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
1393 if (aMin[0] > aMax[0]) {
1394 float aBuf = aMin[0];
1398 if (aMin[1] > aMax[1]) {
1399 float aBuf = aMin[1];
1404 return ((aMin[0]>left) && (aMax[0]<right) && (aMin[1]>bottom) && (aMax[1]<top));
1408 bool VTKViewer_InteractorStyleSALOME::IsInRect(float* thePoint,
1409 const int left, const int top,
1410 const int right, const int bottom)
1413 ComputeWorldToDisplay(thePoint[0], thePoint[1], thePoint[2], aPnt);
1415 return ((aPnt[0]>left) && (aPnt[0]<right) && (aPnt[1]>bottom) && (aPnt[1]<top));
1418 void VTKViewer_InteractorStyleSALOME::SetFilter( const Handle(VTKViewer_Filter)& theFilter )
1420 myFilters[ theFilter->GetId() ] = theFilter;
1423 bool VTKViewer_InteractorStyleSALOME::IsFilterPresent( const int theId )
1425 return myFilters.find( theId ) != myFilters.end();
1428 void VTKViewer_InteractorStyleSALOME::RemoveFilter( const int theId )
1430 if ( IsFilterPresent( theId ) )
1431 myFilters.erase( theId );
1435 bool VTKViewer_InteractorStyleSALOME::IsValid( SALOME_Actor* theActor,
1437 const bool theIsNode )
1439 std::map<int, Handle(VTKViewer_Filter)>::const_iterator anIter;
1440 for ( anIter = myFilters.begin(); anIter != myFilters.end(); ++anIter )
1442 const Handle(VTKViewer_Filter)& aFilter = anIter->second;
1443 if ( theIsNode == aFilter->IsNodeFilter() &&
1444 !aFilter->IsValid( theActor, theId ) )
1450 Handle(VTKViewer_Filter) VTKViewer_InteractorStyleSALOME::GetFilter( const int theId )
1452 return IsFilterPresent( theId ) ? myFilters[ theId ] : Handle(VTKViewer_Filter)();
1455 void VTKViewer_InteractorStyleSALOME::IncrementalPan( const int incrX, const int incrY )
1457 this->PanXY( incrX, incrY, 0, 0 );
1460 void VTKViewer_InteractorStyleSALOME::IncrementalZoom( const int incr )
1462 this->DollyXY( incr, incr );
1465 void VTKViewer_InteractorStyleSALOME::IncrementalRotate( const int incrX, const int incrY )
1467 this->RotateXY( incrX, -incrY );