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"
30 #include "VTKViewer_RenderWindow.h"
31 #include "VTKViewer_Utilities.h"
32 #include "VTKViewer_Trihedron.h"
34 #include "QAD_Config.h"
35 #include "QAD_Application.h"
36 #include "QAD_Desktop.h"
38 #include "SALOME_Selection.h"
39 #include "SALOME_Actor.h"
40 #include "SALOME_ListIteratorOfListIO.hxx"
42 #include <vtkObjectFactory.h>
44 #include <vtkCommand.h>
45 #include <vtkAssemblyNode.h>
46 #include <vtkPicker.h>
47 #include <vtkPointPicker.h>
48 #include <vtkCellPicker.h>
50 #include <vtkUnstructuredGrid.h>
51 #include <vtkExtractEdges.h>
52 #include <vtkPolyDataMapper.h>
53 #include <vtkDataSetCollection.h>
54 #include <vtkImageData.h>
55 #include <vtkFollower.h>
57 #include <qapplication.h>
58 //VRV: porting on Qt 3.0.5
59 #if QT_VERSION >= 0x030005
62 //VRV: porting on Qt 3.0.5
66 extern int SetVisibility(vtkActorCollection* theCollection, int theParam);
67 extern int GetVisibility(vtkActorCollection* theCollection);
69 //----------------------------------------------------------------------------
70 vtkStandardNewMacro(VTKViewer_InteractorStyleSALOME);
71 //----------------------------------------------------------------------------
73 VTKViewer_InteractorStyleSALOME::VTKViewer_InteractorStyleSALOME()
76 this->MotionFactor = 10.0;
77 this->State = VTK_INTERACTOR_STYLE_CAMERA_NONE;
78 this->RadianToDegree = 180.0 / vtkMath::Pi();
79 this->ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE;
83 //----------------------------------------------------------------------------
84 VTKViewer_InteractorStyleSALOME::~VTKViewer_InteractorStyleSALOME()
88 //----------------------------------------------------------------------------
89 void VTKViewer_InteractorStyleSALOME::setTriedron(VTKViewer_Trihedron* theTrihedron){
90 m_Trihedron = theTrihedron;
93 //----------------------------------------------------------------------------
94 void VTKViewer_InteractorStyleSALOME::RotateXY(int dx, int dy)
100 if (this->CurrentRenderer == NULL)
105 int *size = this->CurrentRenderer->GetRenderWindow()->GetSize();
106 this->DeltaElevation = -20.0 / size[1];
107 this->DeltaAzimuth = -20.0 / size[0];
109 rxf = (double)dx * this->DeltaAzimuth * this->MotionFactor;
110 ryf = (double)dy * this->DeltaElevation * this->MotionFactor;
112 cam = this->CurrentRenderer->GetActiveCamera();
115 cam->OrthogonalizeViewUp();
116 ::ResetCameraClippingRange(this->CurrentRenderer);
117 this->Interactor->Render();
120 //----------------------------------------------------------------------------
121 void VTKViewer_InteractorStyleSALOME::PanXY(int x, int y, int oldX, int oldY)
123 TranslateView(x, y, oldX, oldY);
124 //vtkRenderWindowInteractor *rwi = this->Interactor;
125 /* VSV Light follows camera: if (this->CurrentLight)
127 vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
128 this->CurrentLight->SetPosition(cam->GetPosition());
129 this->CurrentLight->SetFocalPoint(cam->GetFocalPoint());
132 this->Interactor->Render();
135 //----------------------------------------------------------------------------
136 void VTKViewer_InteractorStyleSALOME::ControlLblSize(double aOldScale, double aNewScale) {
140 //----------------------------------------------------------------------------
141 void VTKViewer_InteractorStyleSALOME::DollyXY(int dx, int dy)
143 if (this->CurrentRenderer == NULL) return;
145 double dxf = this->MotionFactor * (double)(dx) / (double)(this->CurrentRenderer->GetCenter()[1]);
146 double dyf = this->MotionFactor * (double)(dy) / (double)(this->CurrentRenderer->GetCenter()[1]);
148 double zoomFactor = pow((double)1.1, dxf + dyf);
150 vtkCamera *aCam = this->CurrentRenderer->GetActiveCamera();
151 if (aCam->GetParallelProjection())
152 aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor);
154 aCam->Dolly(zoomFactor);
155 ::ResetCameraClippingRange(this->CurrentRenderer);
158 /* VSV Light follows camera: if (this->CurrentLight)
160 this->CurrentLight->SetPosition(cam->GetPosition());
161 this->CurrentLight->SetFocalPoint(cam->GetFocalPoint());
164 this->Interactor->Render();
167 //----------------------------------------------------------------------------
168 void VTKViewer_InteractorStyleSALOME::SpinXY(int x, int y, int oldX, int oldY)
170 vtkRenderWindowInteractor *rwi = this->Interactor;
173 if (this->CurrentRenderer == NULL)
178 double newAngle = atan2((double)(y - this->CurrentRenderer->GetCenter()[1]),
179 (double)(x - this->CurrentRenderer->GetCenter()[0]));
180 double oldAngle = atan2((double)(oldY -this->CurrentRenderer->GetCenter()[1]),
181 (double)(oldX - this->CurrentRenderer->GetCenter()[0]));
183 newAngle *= this->RadianToDegree;
184 oldAngle *= this->RadianToDegree;
186 cam = this->CurrentRenderer->GetActiveCamera();
187 cam->Roll(newAngle - oldAngle);
188 cam->OrthogonalizeViewUp();
194 //----------------------------------------------------------------------------
195 void VTKViewer_InteractorStyleSALOME::OnMouseMove(int vtkNotUsed(ctrl),
199 myShiftState = shift;
200 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
201 onOperation(QPoint(x, y));
202 else if (ForcedState == VTK_INTERACTOR_STYLE_CAMERA_NONE)
203 onCursorMove(QPoint(x, y));
207 //----------------------------------------------------------------------------
208 void VTKViewer_InteractorStyleSALOME::OnLeftButtonDown(int ctrl, int shift,
211 if (this->HasObserver(vtkCommand::LeftButtonPressEvent)) {
212 this->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL);
215 this->FindPokedRenderer(x, y);
216 if (this->CurrentRenderer == NULL) {
219 myShiftState = shift;
220 // finishing current viewer operation
221 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
223 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
225 myOtherPoint = myPoint = QPoint(x, y);
226 if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
227 startOperation(ForcedState);
230 startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
232 startOperation(VTK_INTERACTOR_STYLE_CAMERA_SELECT);
236 //----------------------------------------------------------------------------
237 void VTKViewer_InteractorStyleSALOME::OnLeftButtonUp(int vtkNotUsed(ctrl),
242 myShiftState = shift;
243 // finishing current viewer operation
244 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
246 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
250 //----------------------------------------------------------------------------
251 void VTKViewer_InteractorStyleSALOME::OnMiddleButtonDown(int ctrl,
255 if (this->HasObserver(vtkCommand::MiddleButtonPressEvent))
257 this->InvokeEvent(vtkCommand::MiddleButtonPressEvent,NULL);
260 this->FindPokedRenderer(x, y);
261 if (this->CurrentRenderer == NULL)
265 myShiftState = shift;
266 // finishing current viewer operation
267 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
269 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
271 myOtherPoint = myPoint = QPoint(x, y);
272 if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
273 startOperation(ForcedState);
277 startOperation(VTK_INTERACTOR_STYLE_CAMERA_PAN);
280 //----------------------------------------------------------------------------
281 void VTKViewer_InteractorStyleSALOME::OnMiddleButtonUp(int vtkNotUsed(ctrl),
286 myShiftState = shift;
287 // finishing current viewer operation
288 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
290 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
294 //----------------------------------------------------------------------------
295 void VTKViewer_InteractorStyleSALOME::OnRightButtonDown(int ctrl,
299 if (this->HasObserver(vtkCommand::RightButtonPressEvent))
301 this->InvokeEvent(vtkCommand::RightButtonPressEvent,NULL);
304 this->FindPokedRenderer(x, y);
305 if (this->CurrentRenderer == NULL)
309 myShiftState = shift;
310 // finishing current viewer operation
311 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
313 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
315 myOtherPoint = myPoint = QPoint(x, y);
316 if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
317 startOperation(ForcedState);
321 startOperation(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
325 //----------------------------------------------------------------------------
326 void VTKViewer_InteractorStyleSALOME::OnRightButtonUp(int vtkNotUsed(ctrl),
331 myShiftState = shift;
332 // finishing current viewer operation
333 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
335 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
339 //----------------------------------------------------------------------------
340 void VTKViewer_InteractorStyleSALOME::PrintSelf(ostream& os, vtkIndent indent)
342 vtkInteractorStyle::PrintSelf(os,indent);
347 const char* imageZoomCursor[] = {
352 "................................",
353 "................................",
354 ".#######........................",
355 "..aaaaaaa.......................",
356 "................................",
357 ".............#####..............",
358 "...........##.aaaa##............",
359 "..........#.aa.....a#...........",
360 ".........#.a.........#..........",
361 ".........#a..........#a.........",
362 "........#.a...........#.........",
363 "........#a............#a........",
364 "........#a............#a........",
365 "........#a............#a........",
366 "........#a............#a........",
367 ".........#...........#.a........",
368 ".........#a..........#a.........",
369 ".........##.........#.a.........",
370 "........#####.....##.a..........",
371 ".......###aaa#####.aa...........",
372 "......###aa...aaaaa.......#.....",
373 ".....###aa................#a....",
374 "....###aa.................#a....",
375 "...###aa...............#######..",
376 "....#aa.................aa#aaaa.",
377 ".....a....................#a....",
378 "..........................#a....",
379 "...........................a....",
380 "................................",
381 "................................",
382 "................................",
383 "................................"};
385 const char* imageRotateCursor[] = {
390 "................................",
391 "................................",
392 "................................",
393 "................................",
394 "........#.......................",
395 ".......#.a......................",
396 "......#######...................",
397 ".......#aaaaa#####..............",
398 "........#..##.a#aa##........##..",
399 ".........a#.aa..#..a#.....##.aa.",
400 ".........#.a.....#...#..##.aa...",
401 ".........#a.......#..###.aa.....",
402 "........#.a.......#a..#aa.......",
403 "........#a.........#..#a........",
404 "........#a.........#a.#a........",
405 "........#a.........#a.#a........",
406 "........#a.........#a.#a........",
407 ".........#.........#a#.a........",
408 "........##a........#a#a.........",
409 "......##.a#.......#.#.a.........",
410 "....##.aa..##.....##.a..........",
411 "..##.aa.....a#####.aa...........",
412 "...aa.........aaa#a.............",
413 "................#.a.............",
414 "...............#.a..............",
415 "..............#.a...............",
416 "...............a................",
417 "................................",
418 "................................",
419 "................................",
420 "................................",
421 "................................"};
423 // loads cursors for viewer operations - zoom, pan, etc...
424 void VTKViewer_InteractorStyleSALOME::loadCursors()
426 myDefCursor = QCursor(ArrowCursor);
427 myHandCursor = QCursor(PointingHandCursor);
428 myPanCursor = QCursor(SizeAllCursor);
429 myZoomCursor = QCursor(QPixmap(imageZoomCursor));
430 myRotateCursor = QCursor(QPixmap(imageRotateCursor));
431 mySpinCursor = QCursor(QPixmap(imageRotateCursor)); // temporarly !!!!!!
432 myGlobalPanCursor = QCursor(CrossCursor);
433 myCursorState = false;
436 // event filter - controls mouse and keyboard events during viewer operations
437 bool VTKViewer_InteractorStyleSALOME::eventFilter(QObject* object, QEvent* event)
439 if (!myGUIWindow) return false;
440 if ( (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::KeyPress) && object != myGUIWindow)
442 qApp->removeEventFilter(this);
443 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
445 return QObject::eventFilter(object, event);
448 // starts Zoom operation (e.g. through menu command)
449 void VTKViewer_InteractorStyleSALOME::startZoom()
451 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
454 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
456 setCursor(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
457 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ZOOM;
458 qApp->installEventFilter(this);
461 // starts Pan operation (e.g. through menu command)
462 void VTKViewer_InteractorStyleSALOME::startPan()
464 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
467 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
469 setCursor(VTK_INTERACTOR_STYLE_CAMERA_PAN);
470 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_PAN;
471 qApp->installEventFilter(this);
474 // starts Rotate operation (e.g. through menu command)
475 void VTKViewer_InteractorStyleSALOME::startRotate()
477 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
480 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
482 setCursor(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
483 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ROTATE;
484 qApp->installEventFilter(this);
487 // starts Spin operation (e.g. through menu command)
488 void VTKViewer_InteractorStyleSALOME::startSpin()
490 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
493 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
495 setCursor(VTK_INTERACTOR_STYLE_CAMERA_SPIN);
496 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_SPIN;
497 qApp->installEventFilter(this);
501 // starts Fit Area operation (e.g. through menu command)
502 void VTKViewer_InteractorStyleSALOME::startFitArea()
504 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
507 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
509 setCursor(VTK_INTERACTOR_STYLE_CAMERA_FIT);
510 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_FIT;
511 qApp->installEventFilter(this);
515 void VTKViewer_InteractorStyleSALOME::ViewFitAll() {
516 int aTriedronWasVisible = false;
518 aTriedronWasVisible =
519 m_Trihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
520 if(aTriedronWasVisible) m_Trihedron->VisibilityOff();
523 if(m_Trihedron->GetVisibleActorCount(CurrentRenderer)){
524 m_Trihedron->VisibilityOff();
525 ::ResetCamera(CurrentRenderer);
527 m_Trihedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn);
528 ::ResetCamera(CurrentRenderer,true);
530 if(aTriedronWasVisible) m_Trihedron->VisibilityOn();
531 else m_Trihedron->VisibilityOff();
535 // starts Global Panning operation (e.g. through menu command)
536 void VTKViewer_InteractorStyleSALOME::startGlobalPan()
538 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
541 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
543 setCursor(VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN);
544 ForcedState = VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN;
546 // store current zoom scale
547 vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
548 myScale = cam->GetParallelScale();
552 // int TriedronWasVisible = false;
554 // TriedronWasVisible =
555 // m_Trihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
556 // if(TriedronWasVisible) m_Trihedron->VisibilityOff();
559 // ::ResetCamera(this->CurrentRenderer);
562 // if(TriedronWasVisible)
563 // m_Trihedron->VisibilityOn();
565 //VTKViewer_RenderWindow* aRW = dynamic_cast<VTKViewer_RenderWindow*>(this->Interactor->GetRenderWindow());
566 if (myGUIWindow) myGUIWindow->update();
568 qApp->installEventFilter(this);
571 // returns TRUE if needs redrawing
572 bool VTKViewer_InteractorStyleSALOME::needsRedrawing()
574 return State == VTK_INTERACTOR_STYLE_CAMERA_ZOOM ||
575 State == VTK_INTERACTOR_STYLE_CAMERA_PAN ||
576 State == VTK_INTERACTOR_STYLE_CAMERA_ROTATE ||
577 State == VTK_INTERACTOR_STYLE_CAMERA_SPIN ||
578 State == VTK_INTERACTOR_STYLE_CAMERA_NONE;
581 // fits viewer contents to rect
582 void VTKViewer_InteractorStyleSALOME::fitRect(const int left,
587 if (this->CurrentRenderer == NULL) return;
590 int x = (left + right)/2;
591 int y = (top + bottom)/2;
592 int *aSize = this->CurrentRenderer->GetRenderWindow()->GetSize();
593 int oldX = aSize[0]/2;
594 int oldY = aSize[1]/2;
595 TranslateView(oldX, oldY, x, y);
598 double dxf = (double)(aSize[0]) / (double)(abs(right - left));
599 double dyf = (double)(aSize[1]) / (double)(abs(bottom - top));
600 double zoomFactor = (dxf + dyf)/2 ;
602 vtkCamera *aCam = this->CurrentRenderer->GetActiveCamera();
603 if(aCam->GetParallelProjection())
604 aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor);
606 aCam->Dolly(zoomFactor);
607 ::ResetCameraClippingRange(this->CurrentRenderer);
610 //vtkRenderWindowInteractor *rwi = this->Interactor;
611 /* VSV Light follows camera: if (this->CurrentLight) {
612 this->CurrentLight->SetPosition(cam->GetPosition());
613 this->CurrentLight->SetFocalPoint(cam->GetFocalPoint());
616 //VTKViewer_RenderWindow* aRW = dynamic_cast<VTKViewer_RenderWindow*>(rwi->GetRenderWindow());
617 myGUIWindow->update();
622 // starts viewer operation (!internal usage!)
623 void VTKViewer_InteractorStyleSALOME::startOperation(int operation)
627 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
628 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
629 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
630 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
631 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
632 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
633 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
634 if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
635 startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
637 if (State != VTK_INTERACTOR_STYLE_CAMERA_SELECT)
638 setCursor(operation);
641 case VTK_INTERACTOR_STYLE_CAMERA_NONE:
643 setCursor(VTK_INTERACTOR_STYLE_CAMERA_NONE);
644 State = ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE;
649 // sets proper cursor for window when viewer operation is activated
650 void VTKViewer_InteractorStyleSALOME::setCursor(const int operation)
652 if (!myGUIWindow) return;
655 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
656 myGUIWindow->setCursor(myZoomCursor);
657 myCursorState = true;
659 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
660 myGUIWindow->setCursor(myPanCursor);
661 myCursorState = true;
663 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
664 myGUIWindow->setCursor(myRotateCursor);
665 myCursorState = true;
667 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
668 myGUIWindow->setCursor(mySpinCursor);
669 myCursorState = true;
671 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
672 myGUIWindow->setCursor(myGlobalPanCursor);
673 myCursorState = true;
675 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
676 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
677 myGUIWindow->setCursor(myHandCursor);
678 myCursorState = true;
680 case VTK_INTERACTOR_STYLE_CAMERA_NONE:
682 myGUIWindow->setCursor(myDefCursor);
683 myCursorState = false;
688 // called when viewer operation started (!put necessary initialization here!)
689 void VTKViewer_InteractorStyleSALOME::onStartOperation()
691 if (!myGUIWindow) return;
692 // VSV: LOD actor activisation
693 // this->Interactor->GetRenderWindow()->SetDesiredUpdateRate(this->Interactor->GetDesiredUpdateRate());
695 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
696 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
698 QPainter p(myGUIWindow);
699 p.setPen(Qt::lightGray);
700 p.setRasterOp(Qt::XorROP);
701 p.drawRect(QRect(myPoint, myOtherPoint));
704 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
705 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
706 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
707 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
708 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
713 // called when viewer operation finished (!put necessary post-processing here!)
714 void VTKViewer_InteractorStyleSALOME::onFinishOperation()
716 if (!myGUIWindow) return;
719 QAD_Study* aActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
720 SALOME_Selection* aSel = SALOME_Selection::Selection( aActiveStudy->getSelection() );
721 vtkRenderWindowInteractor *rwi = this->Interactor;
723 // VSV: LOD actor activisation
724 // rwi->GetRenderWindow()->SetDesiredUpdateRate(rwi->GetStillUpdateRate());
726 int aSelectionMode = aSel->SelectionMode();
727 bool aSelActiveCompOnly = aSel->IsSelectActiveCompOnly();
730 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
731 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
733 QPainter p(myGUIWindow);
734 p.setPen(Qt::lightGray);
735 p.setRasterOp(Qt::XorROP);
736 QRect rect(myPoint, myOtherPoint);
738 rect = rect.normalize();
739 if (State == VTK_INTERACTOR_STYLE_CAMERA_FIT) {
740 // making fit rect opeation
745 y1 = h - rect.top() - 1;
747 y2 = h - rect.bottom() - 1;
748 fitRect(x1, y1, x2, y2);
751 if (myPoint == myOtherPoint) {
752 // process point selection
756 y = h - myPoint.y() - 1;
757 vtkActorCollection* listactors = NULL;
758 this->FindPokedRenderer(x, y);
759 rwi->StartPickCallback();
761 // vtkPicker* aPicker = vtkPicker::SafeDownCast(rwi->GetPicker());
763 // aPicker->SetTolerance(0.01);
765 rwi->GetPicker()->Pick(x, y, 0.0, this->CurrentRenderer);
767 if ( rwi->GetPicker()->IsA("vtkCellPicker") ) {
768 vtkCellPicker* picker;
769 if ( (picker = vtkCellPicker::SafeDownCast(rwi->GetPicker())) ) {
770 MESSAGE ( " CellId : " << picker->GetCellId() );
771 if ( picker->GetCellId() >= 0 ) {
772 vtkActor* ac = picker->GetActor();
773 if ( ac->IsA("SALOME_Actor") ) {
774 SALOME_Actor* SActor = SALOME_Actor::SafeDownCast( ac );
775 MESSAGE ( " NAME Actor : " << SActor->getName() );
777 //Cell selection //////////////////////////////////// NB
778 if ( aSelectionMode == 3 ) {
779 if ( SActor->hasIO() ) {
780 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
781 // Look in the current selection
782 SALOME_ListIteratorOfListIO It(aSel->StoredIObjects());
783 Standard_Boolean IsSelected = false;
784 for(;It.More();It.Next()) {
785 Handle(SALOME_InteractiveObject) IOS = It.Value();
786 if(IO->isSame(IOS)) {
788 IO = IOS; //Added by SRN, fix SAL1307
793 // This IO is already in the selection
795 bool add = aSel->AddOrRemoveIndex( IO, picker->GetCellId(), myShiftState, false );
796 //Sel->RemoveIObject(IO);
800 this->HighlightProp( NULL );
801 aSel->ClearIObjects();
803 bool add = aSel->AddOrRemoveIndex( IO, picker->GetCellId(), myShiftState, false );
804 aSel->AddIObject( IO, false );
808 //Edge selection ////////////////////////// NB
809 else if ( aSelectionMode == 2 ) {
811 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
812 float pickPosition[3],pcoords[3],closestPoint[3],weights[3],dist1=1000000.0,dist2=0;
813 int subId,edgeId=-10,pickedID,result;
814 pickedID = picker->GetCellId();
815 picker->GetPickPosition(pickPosition);
816 if (vtkDataSet* UGrid = SActor->GetMapper()->GetInput()){
817 if (vtkCell* pickedCell = UGrid->GetCell(pickedID)){
819 for (int i = 0, iEnd = pickedCell->GetNumberOfEdges(); i < iEnd; i++){
820 vtkCell* edge = pickedCell->GetEdge(i);
821 if(vtkLine* line = vtkLine::SafeDownCast(edge)){
822 result = line->EvaluatePosition(pickPosition,closestPoint,subId,pcoords,dist2,weights);
829 MESSAGE("edgeID transformed = "<<edgeId);
830 // Look in the current selection
831 SALOME_ListIteratorOfListIO It(aSel->StoredIObjects());
832 Standard_Boolean IsSelected = false;
833 for(;It.More();It.Next()) {
834 Handle(SALOME_InteractiveObject) IOS = It.Value();
835 if(IO->isSame(IOS)) {
836 IO = IOS; //Added by SRN, fix SAL1307
842 this->HighlightProp( NULL );
843 aSel->ClearIObjects();
845 aSel->SetSelectionMode(2, true);
846 bool add = aSel->AddOrRemoveIndex( IO, pickedID, true, false);
848 add = aSel->AddOrRemoveIndex( IO, -edgeId-1, true, true );
849 aSel->AddIObject( IO, false );
855 this->HighlightProp( NULL );
856 aSel->ClearIObjects();
860 } else if ( rwi->GetPicker()->IsA("vtkPointPicker") ) {
861 vtkPointPicker* picker;
862 if ( (picker = vtkPointPicker::SafeDownCast(rwi->GetPicker())) ) {
863 MESSAGE ( " PointId : " << picker->GetPointId() );
864 if ( picker->GetPointId() >= 0 ) {
865 vtkActor* ac = picker->GetActor();
866 if ( ac->IsA("SALOME_Actor") ) {
867 SALOME_Actor* SActor = SALOME_Actor::SafeDownCast( ac );
868 MESSAGE ( " NAME Actor : " << SActor->getName() );
869 if ( SActor->hasIO() ) {
870 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
873 if (aSelActiveCompOnly &&
874 strcmp(aActiveComponent->ComponentDataType(), IO->getComponentDataType()) != 0) {
877 // Look in the current selection
878 SALOME_ListIteratorOfListIO It(aSel->StoredIObjects());
879 Standard_Boolean IsSelected = false;
880 for(;It.More();It.Next()) {
881 Handle(SALOME_InteractiveObject) IOS = It.Value();
882 if(IO->isSame(IOS)) {
883 IO = IOS; //Added by SRN, fix SAL1307
889 // This IO is already in the selection
890 bool add = aSel->AddOrRemoveIndex( IO, picker->GetPointId(), myShiftState, false );
893 this->HighlightProp( NULL );
894 aSel->ClearIObjects();
896 bool add = aSel->AddOrRemoveIndex( IO, picker->GetPointId(), myShiftState, false );
897 aSel->AddIObject( IO, false );
902 this->HighlightProp( NULL );
903 aSel->ClearIObjects();
908 if ( (picker = vtkPicker::SafeDownCast(rwi->GetPicker())) ) {
909 listactors = picker->GetActors();
911 if ( listactors->GetNumberOfItems() == 0 ) {
912 // No selection clear all
913 this->PropPicked = 0;
914 this->HighlightProp( NULL );
915 aSel->ClearIObjects();
918 listactors->InitTraversal();
919 ac = listactors->GetNextActor();
920 if ( ac->IsA("SALOME_Actor") ) {
921 SALOME_Actor* SActor = SALOME_Actor::SafeDownCast( ac );
922 if ( SActor->hasIO() ) {
924 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
925 // Look in the current selection
926 SALOME_ListIteratorOfListIO It(aSel->StoredIObjects());
927 Standard_Boolean IsSelected = false;
928 for(;It.More();It.Next()) {
929 Handle(SALOME_InteractiveObject) IOS = It.Value();
930 if( IO->isSame(IOS) ) {
931 IO = IOS; //Added by SRN, fix SAL1307
937 // This IO is already in the selection
939 aSel->RemoveIObject(IO);
944 this->HighlightProp( NULL );
945 aSel->ClearIObjects();
947 aSel->AddIObject( IO, false );
952 rwi->EndPickCallback();
955 //processing rectangle selection
956 SALOMEDS::SComponent_var aActiveComponent = SALOMEDS::SComponent::
957 _narrow(aActiveStudy->getStudyDocument()->
958 FindObject(QAD_Application::getDesktop()->getActiveComponent()));
959 if(aSelActiveCompOnly && aActiveComponent->_is_nil()) return;
960 rwi->StartPickCallback();
963 this->PropPicked = 0;
964 this->HighlightProp( NULL );
965 aSel->ClearIObjects();
969 vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
970 QRect rect(myPoint, myOtherPoint);
971 rect = rect.normalize();
976 y1 = h - rect.top() - 1;
978 y2 = h - rect.bottom() - 1;
980 switch (aSelectionMode) {
981 case 1: // Nodes selection
983 if (! rwi->GetPicker()->IsA("vtkPointPicker") ) break;
984 vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(rwi->GetPicker());
985 vtkActorCollection* aListActors = this->CurrentRenderer->GetActors();
986 aListActors->InitTraversal();
988 for (int k = 0; k < aListActors->GetNumberOfItems(); k++) {
989 aActor = aListActors->GetNextActor();
990 if (aActor != NULL) {
991 if (aActor->GetVisibility() == 0)
993 vtkAbstractMapper3D* aMapper3D = aActor->GetMapper();
994 if ((aMapper3D != NULL) && (aActor->IsA("SALOME_Actor"))) {
995 SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor);
997 if ((SActor != NULL) && (SActor->hasIO())) {
998 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
1001 if (aSelActiveCompOnly &&
1002 strcmp(aActiveComponent->ComponentDataType(), IO->getComponentDataType()) != 0) {
1007 vtkVolumeMapper* aVolumeMapper;
1008 vtkDataSet* aDataSet;
1010 if ( (aMapper = vtkMapper::SafeDownCast(aMapper3D)) != NULL ) {
1011 aDataSet = aMapper->GetInput();
1012 } else if ((aVolumeMapper = vtkVolumeMapper::SafeDownCast(aMapper3D)) != NULL ){
1013 aDataSet = aVolumeMapper->GetInput();
1018 for (int i=0; i < aDataSet->GetNumberOfPoints(); i++) {
1020 aPoint = aDataSet->GetPoint(i);
1021 if (IsInRect(aPoint, x1, y1, x2, y2)) {
1023 ComputeWorldToDisplay(aPoint[0],
1026 aPointPicker->Pick(aDisp[0], aDisp[1], 0.0, CurrentRenderer);
1027 if ( aPointPicker->GetPointId() >= 0) { // && (!aSel->IsIndexSelected(IO, aPointPicker->GetPointId()))) {
1028 aSel->AddOrRemoveIndex(IO, aPointPicker->GetPointId(), true, false);
1029 aSel->AddIObject(IO, false);
1040 case 2: // edges selection
1041 case 3: // triangles selection
1043 aSel->SetSelectionMode(aSelectionMode,true);
1044 if (!rwi->GetPicker()->IsA("vtkCellPicker") ) break;
1045 vtkCellPicker* aCellPicker = vtkCellPicker::SafeDownCast(rwi->GetPicker());
1046 vtkActorCollection* aListActors = this->CurrentRenderer->GetActors();
1047 aListActors->InitTraversal();
1049 for (int k = 0, kEnd = aListActors->GetNumberOfItems(); k < kEnd; k++){
1050 vtkActor* aActor = aListActors->GetNextActor();
1051 if (vtkActor* aActor = aListActors->GetNextActor()){
1052 if (aActor->GetVisibility() == 0) continue;
1053 if(SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor)) {
1054 if(SActor->hasIO()) {
1055 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
1056 if(IO.IsNull()) continue;
1057 if(aSelActiveCompOnly) {
1058 if(strcmp(aActiveComponent->ComponentDataType(),IO->getComponentDataType()) != 0)
1061 if(vtkDataSet* aDataSet = SActor->GetMapper()->GetInput()){
1062 for(int i = 0, iEnd = aDataSet->GetNumberOfCells(); i < iEnd; i++){
1063 if(vtkCell* aCell = aDataSet->GetCell(i)){
1064 if(IsInRect(aCell, x1, y1, x2, y2)){
1065 float* aBounds = aCell->GetBounds();
1067 aCenter[0] =(aBounds[0] + aBounds[1])/2; // Center X
1068 aCenter[1] =(aBounds[2] + aBounds[3])/2; // Center Y
1069 aCenter[2] =(aBounds[4] + aBounds[5])/2; // Center Z
1071 ComputeWorldToDisplay(aCenter[0],aCenter[1],aCenter[2],aDisp);
1072 aCellPicker->Pick(aDisp[0], aDisp[1], 0.0, CurrentRenderer);
1073 if(aCellPicker->GetCellId() >= 0 && !aSel->IsIndexSelected(IO,aCellPicker->GetCellId())){
1074 aSel->AddOrRemoveIndex( IO, aCellPicker->GetCellId(), true, false);
1075 aSel->AddIObject( IO, false );
1087 case 4: // objects selection
1089 vtkActorCollection* aListActors = this->CurrentRenderer->GetActors();
1090 aListActors->InitTraversal();
1092 SALOME_ListIO aListIO;
1093 for (int k = 0; k < aListActors->GetNumberOfItems(); k++) {
1094 aActor = aListActors->GetNextActor();
1096 if (aActor->GetVisibility() == 0)
1098 if ( aActor->IsA("SALOME_Actor") ) {
1099 SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor);
1100 if ( aSActor->hasIO() && IsInRect(aSActor, x1, y1, x2, y2)) {
1101 Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
1104 if (aSelActiveCompOnly &&
1105 strcmp(aActiveComponent->ComponentDataType(), aIO->getComponentDataType()) != 0) {
1108 if (aListIO.IsEmpty()) {
1109 aListIO.Append( aIO );
1111 SALOME_ListIteratorOfListIO It(aListIO);
1112 bool isStored = false;
1113 for(;It.More();It.Next()) {
1114 Handle(SALOME_InteractiveObject) IOS = It.Value();
1115 if( aIO->isSame(IOS) ) {
1116 aIO = IOS; //Added by SRN, fix SAL1307
1122 aListIO.Append( aIO );
1128 if (!aListIO.IsEmpty()) {
1129 SALOME_ListIteratorOfListIO It(aListIO);
1130 for(;It.More();It.Next()) {
1131 Handle(SALOME_InteractiveObject) IOS = It.Value();
1133 aSel->AddIObject( IOS, false );
1138 rwi->EndPickCallback();
1140 aActiveStudy->update3dViewers();
1144 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
1145 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
1146 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
1147 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
1149 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
1154 y = h - myPoint.y() - 1;
1159 if (myGUIWindow) myGUIWindow->update();
1163 // called during viewer operation when user moves mouse (!put necessary processing here!)
1164 void VTKViewer_InteractorStyleSALOME::onOperation(QPoint mousePos)
1166 if (!myGUIWindow) return;
1168 GetInteractor()->GetSize(w, h);
1170 case VTK_INTERACTOR_STYLE_CAMERA_PAN:
1172 // processing panning
1173 //this->FindPokedCamera(mousePos.x(), mousePos.y());
1174 this->PanXY(mousePos.x(), myPoint.y(), myPoint.x(), mousePos.y());
1178 case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
1180 // processing zooming
1181 //this->FindPokedCamera(mousePos.x(), mousePos.y());
1182 this->DollyXY(mousePos.x() - myPoint.x(), mousePos.y() - myPoint.y());
1186 case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
1188 // processing rotation
1189 //this->FindPokedCamera(mousePos.x(), mousePos.y());
1190 this->RotateXY(mousePos.x() - myPoint.x(), myPoint.y() - mousePos.y());
1194 case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
1196 // processing spinning
1197 //this->FindPokedCamera(mousePos.x(), mousePos.y());
1198 this->SpinXY(mousePos.x(), mousePos.y(), myPoint.x(), myPoint.y());
1202 case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
1206 case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
1209 setCursor(VTK_INTERACTOR_STYLE_CAMERA_SELECT);
1211 case VTK_INTERACTOR_STYLE_CAMERA_FIT:
1213 QPainter p(myGUIWindow);
1214 p.setPen(Qt::lightGray);
1215 p.setRasterOp(Qt::XorROP);
1216 p.drawRect(QRect(myPoint, myOtherPoint));
1217 myOtherPoint = mousePos;
1218 p.drawRect(QRect(myPoint, myOtherPoint));
1222 this->LastPos[0] = mousePos.x();
1223 this->LastPos[1] = h - mousePos.y() - 1;
1226 // called when user moves mouse inside viewer window and there is no active viewer operation
1227 // (!put necessary processing here!)
1228 void VTKViewer_InteractorStyleSALOME::onCursorMove(QPoint mousePos) {
1229 // processing highlighting
1230 QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
1231 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
1233 vtkRenderWindowInteractor *rwi = this->Interactor;
1236 x = mousePos.x(); y = h - mousePos.y() - 1;
1238 this->FindPokedRenderer(x,y);
1239 rwi->StartPickCallback();
1240 rwi->GetPicker()->Pick(x, y, 0.0, this->CurrentRenderer);
1242 if ( rwi->GetPicker()->IsA("vtkPicker") ) {
1243 vtkPicker* picker = vtkPicker::SafeDownCast(rwi->GetPicker());
1244 vtkActor* ac = picker->GetActor();
1247 if ( ac->IsA("SALOME_Actor") ) {
1248 SALOME_Actor* SActor = SALOME_Actor::SafeDownCast( ac );
1249 if ( preview != SActor ) {
1250 if ( preview != NULL ) {
1251 preview->SetPreSelected( false );
1255 if ( SActor->hasIO() ) {
1256 Handle( SALOME_InteractiveObject) IO = SActor->getIO();
1258 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
1259 Standard_Boolean IsSelected = false;
1260 for(;It.More();It.Next()) {
1261 Handle(SALOME_InteractiveObject) IOS = It.Value();
1262 if(IO->isSame(IOS)) {
1268 if ( !IsSelected ) {
1269 // Find All actors with same IO
1270 vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
1271 theActors->InitTraversal();
1272 vtkActor *ac = theActors->GetNextActor();
1274 if ( ac->IsA("SALOME_Actor") ) {
1275 SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
1276 if ( anActor->hasIO() ) {
1277 Handle(SALOME_InteractiveObject) IOS = anActor->getIO();
1278 if(IO->isSame(IOS)) {
1279 anActor->SetPreSelected( true );
1283 ac = theActors->GetNextActor();
1285 // MESSAGE ( " NAME PREVIEW " << SActor->getName() );
1292 vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
1293 theActors->InitTraversal();
1294 vtkActor *ac = theActors->GetNextActor();
1296 if ( ac->IsA("SALOME_Actor") ) {
1297 SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
1298 anActor->SetPreSelected( false );
1300 ac = theActors->GetNextActor();
1304 this->LastPos[0] = x;
1305 this->LastPos[1] = y;
1308 // called on finsh GlobalPan operation
1309 void VTKViewer_InteractorStyleSALOME::Place(const int theX, const int theY)
1311 if (this->CurrentRenderer == NULL) {
1316 int *aSize = this->CurrentRenderer->GetRenderWindow()->GetSize();
1317 int centerX = aSize[0]/2;
1318 int centerY = aSize[1]/2;
1320 TranslateView(centerX, centerY, theX, theY);
1322 // restore zoom scale
1323 vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
1324 cam->SetParallelScale(myScale);
1325 ::ResetCameraClippingRange(this->CurrentRenderer);
1327 /* VSV Light follows camera: if (this->CurrentLight) {
1328 this->CurrentLight->SetPosition(cam->GetPosition());
1329 this->CurrentLight->SetFocalPoint(cam->GetFocalPoint());
1331 //VTKViewer_RenderWindow* aRW = dynamic_cast<VTKViewer_RenderWindow*>(this->Interactor->GetRenderWindow());
1332 if (myGUIWindow) myGUIWindow->update();
1338 // Translates view from Point to Point
1339 void VTKViewer_InteractorStyleSALOME::TranslateView(int toX, int toY, int fromX, int fromY)
1341 vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
1342 double viewFocus[4], focalDepth, viewPoint[3];
1343 float newPickPoint[4], oldPickPoint[4], motionVector[3];
1344 cam->GetFocalPoint(viewFocus);
1346 this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1],
1347 viewFocus[2], viewFocus);
1348 focalDepth = viewFocus[2];
1350 this->ComputeDisplayToWorld(double(toX), double(toY),
1351 focalDepth, newPickPoint);
1352 this->ComputeDisplayToWorld(double(fromX),double(fromY),
1353 focalDepth, oldPickPoint);
1355 // camera motion is reversed
1356 motionVector[0] = oldPickPoint[0] - newPickPoint[0];
1357 motionVector[1] = oldPickPoint[1] - newPickPoint[1];
1358 motionVector[2] = oldPickPoint[2] - newPickPoint[2];
1360 cam->GetFocalPoint(viewFocus);
1361 cam->GetPosition(viewPoint);
1362 cam->SetFocalPoint(motionVector[0] + viewFocus[0],
1363 motionVector[1] + viewFocus[1],
1364 motionVector[2] + viewFocus[2]);
1365 cam->SetPosition(motionVector[0] + viewPoint[0],
1366 motionVector[1] + viewPoint[1],
1367 motionVector[2] + viewPoint[2]);
1371 /// Checks: is the given Actor within display coordinates?
1372 bool VTKViewer_InteractorStyleSALOME::IsInRect(vtkActor* theActor,
1373 const int left, const int top,
1374 const int right, const int bottom)
1376 float* aBounds = theActor->GetBounds();
1377 float aMin[3], aMax[3];
1378 ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
1379 ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
1380 if (aMin[0] > aMax[0]) {
1381 float aBuf = aMin[0];
1385 if (aMin[1] > aMax[1]) {
1386 float aBuf = aMin[1];
1391 return ((aMin[0]>left) && (aMax[0]<right) && (aMin[1]>bottom) && (aMax[1]<top));
1395 /// Checks: is the given Cell within display coordinates?
1396 bool VTKViewer_InteractorStyleSALOME::IsInRect(vtkCell* theCell,
1397 const int left, const int top,
1398 const int right, const int bottom)
1400 float* aBounds = theCell->GetBounds();
1401 float aMin[3], aMax[3];
1402 ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
1403 ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
1404 if (aMin[0] > aMax[0]) {
1405 float aBuf = aMin[0];
1409 if (aMin[1] > aMax[1]) {
1410 float aBuf = aMin[1];
1415 return ((aMin[0]>left) && (aMax[0]<right) && (aMin[1]>bottom) && (aMax[1]<top));
1419 bool VTKViewer_InteractorStyleSALOME::IsInRect(float* thePoint,
1420 const int left, const int top,
1421 const int right, const int bottom)
1424 ComputeWorldToDisplay(thePoint[0], thePoint[1], thePoint[2], aPnt);
1426 return ((aPnt[0]>left) && (aPnt[0]<right) && (aPnt[1]>bottom) && (aPnt[1]<top));