1 #include "SALOME_Actor.h"
3 #include <qapplication.h>
5 #include <vtkActorCollection.h>
6 #include <vtkRenderWindow.h>
7 #include <vtkRenderer.h>
10 #include "QtxAction.h"
12 #include "SUIT_Session.h"
13 #include "SUIT_ToolButton.h"
14 #include "SUIT_MessageBox.h"
16 #include "SUIT_Tools.h"
17 #include "SUIT_ResourceMgr.h"
19 #include "VTKViewer_Transform.h"
20 #include "VTKViewer_Utilities.h"
22 #include "SVTK_Trihedron.h"
23 #include "SVTK_ViewWindow.h"
24 #include "SVTK_ViewModel.h"
25 #include "SVTK_RenderWindow.h"
26 #include "SVTK_RenderWindowInteractor.h"
27 #include "SVTK_InteractorStyle.h"
29 #include "SALOME_ListIteratorOfListIO.hxx"
31 #include "SVTK_SelectorDef.h"
33 #include "VTKViewer_Algorithm.h"
34 #include "SVTK_Functor.h"
36 //----------------------------------------------------------------------------
38 ::SVTK_ViewWindow( SUIT_Desktop* theDesktop,
39 SVTK_Viewer* theModel)
40 : SUIT_ViewWindow(theDesktop)
43 mySelector = new SVTK_SelectorDef();
44 connect(this,SIGNAL(selectionChanged()),theModel,SLOT(onSelectionChanged()));
46 myTransform = VTKViewer_Transform::New();
47 myTrihedron = SVTK_Trihedron::New();
48 myRenderer = vtkRenderer::New() ;
50 myTrihedron->AddToRender( myRenderer );
52 myRenderWindow = new SVTK_RenderWindow( this, "RenderWindow" );
53 setCentralWidget(myRenderWindow);
54 myRenderWindow->setFocusPolicy( StrongFocus );
55 myRenderWindow->setFocus();
57 myRenderWindow->getRenderWindow()->AddRenderer( myRenderer );
59 myRenderer->GetActiveCamera()->ParallelProjectionOn();
60 myRenderer->LightFollowCameraOn();
61 myRenderer->TwoSidedLightingOn();
63 // Set BackgroundColor
64 QString BgrColorRed = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorRed");
65 QString BgrColorGreen = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorGreen");
66 QString BgrColorBlue = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorBlue");
68 if( !BgrColorRed.isEmpty() && !BgrColorGreen.isEmpty() && !BgrColorBlue.isEmpty() )
69 myRenderer->SetBackground( BgrColorRed.toInt()/255., BgrColorGreen.toInt()/255., BgrColorBlue.toInt()/255. );
71 myRenderer->SetBackground( 0, 0, 0 );
73 // Create an interactor.
74 myRWInteractor = SVTK_RenderWindowInteractor::New();
75 myRWInteractor->SetRenderWindow( myRenderWindow->getRenderWindow() );
76 myRWInteractor->setViewWindow( this );
78 SVTK_InteractorStyle* RWS = SVTK_InteractorStyle::New();
79 RWS->setGUIWindow( myRenderWindow );
80 RWS->setViewWindow( this );
82 myRWInteractor->SetInteractorStyle( RWS );
83 myRWInteractor->Initialize();
85 RWS->setTriedron( myTrihedron );
86 RWS->FindPokedRenderer( 0, 0 );
88 SetSelectionMode(ActorSelection);
90 setCentralWidget( myRenderWindow );
92 myToolBar = new QToolBar(this);
93 myToolBar->setCloseMode(QDockWindow::Undocked);
94 myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
99 connect( myRenderWindow, SIGNAL(KeyPressed( QKeyEvent* )),
100 this, SLOT(onKeyPressed( QKeyEvent* )) );
101 connect( myRenderWindow, SIGNAL(KeyReleased( QKeyEvent* )),
102 this, SLOT(onKeyReleased( QKeyEvent* )) );
103 connect( myRenderWindow, SIGNAL(MouseButtonPressed( QMouseEvent* )),
104 this, SLOT(onMousePressed( QMouseEvent* )) );
105 connect( myRenderWindow, SIGNAL(MouseButtonReleased( QMouseEvent* )),
106 this, SLOT(onMouseReleased( QMouseEvent* )) );
107 connect( myRenderWindow, SIGNAL(MouseDoubleClicked( QMouseEvent* )),
108 this, SLOT(onMouseDoubleClicked( QMouseEvent* )) );
109 connect( myRenderWindow, SIGNAL(MouseMove( QMouseEvent* )),
110 this, SLOT(onMouseMoving( QMouseEvent* )) );
112 connect( myRWInteractor, SIGNAL(RenderWindowModified()),
113 myRenderWindow, SLOT(update()) );
114 connect( myRWInteractor, SIGNAL(contextMenuRequested( QContextMenuEvent * )),
115 this, SIGNAL(contextMenuRequested( QContextMenuEvent * )) );
120 //----------------------------------------------------------------------------
124 myTransform->Delete();
125 // In order to ensure that the interactor unregisters
126 // this RenderWindow, we assign a NULL RenderWindow to
127 // it before deleting it.
128 myRWInteractor->SetRenderWindow( NULL );
129 myRWInteractor->Delete();
132 myRenderer->RemoveAllProps();
133 //m_Renderer->Delete() ;
134 myTrihedron->Delete();
137 //----------------------------------------------------------------------------
142 myRWInteractor->GetSInteractorStyle()->startZoom();
145 //----------------------------------------------------------------------------
150 myRWInteractor->GetSInteractorStyle()->startPan();
153 //----------------------------------------------------------------------------
158 myRWInteractor->GetSInteractorStyle()->startRotate();
161 //----------------------------------------------------------------------------
164 ::activateGlobalPanning()
166 if(myTrihedron->GetVisibleActorCount(myRenderer))
167 myRWInteractor->GetSInteractorStyle()->startGlobalPan();
170 //----------------------------------------------------------------------------
173 ::activateWindowFit()
175 myRWInteractor->GetSInteractorStyle()->startFitArea();
178 //----------------------------------------------------------------------------
183 if (!myActionsMap.isEmpty()) return;
185 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
190 aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
191 tr( "MNU_DUMP_VIEW" ), 0, this);
192 aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
193 connect(aAction, SIGNAL(activated()), this, SLOT(onDumpView()));
194 myActionsMap[ DumpId ] = aAction;
197 aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
198 tr( "MNU_FITALL" ), 0, this);
199 aAction->setStatusTip(tr("DSC_FITALL"));
200 connect(aAction, SIGNAL(activated()), this, SLOT(onFitAll()));
201 myActionsMap[ FitAllId ] = aAction;
204 aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
205 tr( "MNU_FITRECT" ), 0, this);
206 aAction->setStatusTip(tr("DSC_FITRECT"));
207 connect(aAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
208 myActionsMap[ FitRectId ] = aAction;
211 aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
212 tr( "MNU_ZOOM_VIEW" ), 0, this);
213 aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
214 connect(aAction, SIGNAL(activated()), this, SLOT(activateZoom()));
215 myActionsMap[ ZoomId ] = aAction;
218 aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
219 tr( "MNU_PAN_VIEW" ), 0, this);
220 aAction->setStatusTip(tr("DSC_PAN_VIEW"));
221 connect(aAction, SIGNAL(activated()), this, SLOT(activatePanning()));
222 myActionsMap[ PanId ] = aAction;
225 aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
226 tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
227 aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
228 connect(aAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
229 myActionsMap[ GlobalPanId ] = aAction;
232 aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
233 tr( "MNU_ROTATE_VIEW" ), 0, this);
234 aAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
235 connect(aAction, SIGNAL(activated()), this, SLOT(activateRotation()));
236 myActionsMap[ RotationId ] = aAction;
239 aAction = new QtxAction(tr("MNU_FRONT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
240 tr( "MNU_FRONT_VIEW" ), 0, this);
241 aAction->setStatusTip(tr("DSC_FRONT_VIEW"));
242 connect(aAction, SIGNAL(activated()), this, SLOT(onFrontView()));
243 myActionsMap[ FrontId ] = aAction;
245 aAction = new QtxAction(tr("MNU_BACK_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
246 tr( "MNU_BACK_VIEW" ), 0, this);
247 aAction->setStatusTip(tr("DSC_BACK_VIEW"));
248 connect(aAction, SIGNAL(activated()), this, SLOT(onBackView()));
249 myActionsMap[ BackId ] = aAction;
251 aAction = new QtxAction(tr("MNU_TOP_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
252 tr( "MNU_TOP_VIEW" ), 0, this);
253 aAction->setStatusTip(tr("DSC_TOP_VIEW"));
254 connect(aAction, SIGNAL(activated()), this, SLOT(onTopView()));
255 myActionsMap[ TopId ] = aAction;
257 aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
258 tr( "MNU_BOTTOM_VIEW" ), 0, this);
259 aAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
260 connect(aAction, SIGNAL(activated()), this, SLOT(onBottomView()));
261 myActionsMap[ BottomId ] = aAction;
263 aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
264 tr( "MNU_LEFT_VIEW" ), 0, this);
265 aAction->setStatusTip(tr("DSC_LEFT_VIEW"));
266 connect(aAction, SIGNAL(activated()), this, SLOT(onLeftView()));
267 myActionsMap[ LeftId ] = aAction;
269 aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
270 tr( "MNU_RIGHT_VIEW" ), 0, this);
271 aAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
272 connect(aAction, SIGNAL(activated()), this, SLOT(onRightView()));
273 myActionsMap[ RightId ] = aAction;
276 aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
277 tr( "MNU_RESET_VIEW" ), 0, this);
278 aAction->setStatusTip(tr("DSC_RESET_VIEW"));
279 connect(aAction, SIGNAL(activated()), this, SLOT(onResetView()));
280 myActionsMap[ ResetId ] = aAction;
282 // onViewTrihedron: Shows - Hides Trihedron
283 aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
284 tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
285 aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
286 connect(aAction, SIGNAL(activated()), this, SLOT(onViewTrihedron()));
287 myActionsMap[ ViewTrihedronId ] = aAction;
290 //----------------------------------------------------------------------------
295 myActionsMap[DumpId]->addTo(myToolBar);
296 myActionsMap[ViewTrihedronId]->addTo(myToolBar);
298 SUIT_ToolButton* aScaleBtn = new SUIT_ToolButton(myToolBar);
299 aScaleBtn->AddAction(myActionsMap[FitAllId]);
300 aScaleBtn->AddAction(myActionsMap[FitRectId]);
301 aScaleBtn->AddAction(myActionsMap[ZoomId]);
303 SUIT_ToolButton* aPanningBtn = new SUIT_ToolButton(myToolBar);
304 aPanningBtn->AddAction(myActionsMap[PanId]);
305 aPanningBtn->AddAction(myActionsMap[GlobalPanId]);
307 myActionsMap[RotationId]->addTo(myToolBar);
309 SUIT_ToolButton* aViewsBtn = new SUIT_ToolButton(myToolBar);
310 aViewsBtn->AddAction(myActionsMap[FrontId]);
311 aViewsBtn->AddAction(myActionsMap[BackId]);
312 aViewsBtn->AddAction(myActionsMap[TopId]);
313 aViewsBtn->AddAction(myActionsMap[BottomId]);
314 aViewsBtn->AddAction(myActionsMap[LeftId]);
315 aViewsBtn->AddAction(myActionsMap[RightId]);
317 myActionsMap[ResetId]->addTo(myToolBar);
320 //----------------------------------------------------------------------------
325 vtkCamera* camera = myRenderer->GetActiveCamera();
326 camera->SetPosition(1,0,0);
327 camera->SetViewUp(0,0,1);
328 camera->SetFocalPoint(0,0,0);
332 //----------------------------------------------------------------------------
337 vtkCamera* camera = myRenderer->GetActiveCamera();
338 camera->SetPosition(-1,0,0);
339 camera->SetViewUp(0,0,1);
340 camera->SetFocalPoint(0,0,0);
344 //----------------------------------------------------------------------------
349 vtkCamera* camera = myRenderer->GetActiveCamera();
350 camera->SetPosition(0,0,1);
351 camera->SetViewUp(0,1,0);
352 camera->SetFocalPoint(0,0,0);
356 //----------------------------------------------------------------------------
361 vtkCamera* camera = myRenderer->GetActiveCamera();
362 camera->SetPosition(0,0,-1);
363 camera->SetViewUp(0,1,0);
364 camera->SetFocalPoint(0,0,0);
368 //----------------------------------------------------------------------------
373 vtkCamera* camera = myRenderer->GetActiveCamera();
374 camera->SetPosition(0,-1,0);
375 camera->SetViewUp(0,0,1);
376 camera->SetFocalPoint(0,0,0);
380 //----------------------------------------------------------------------------
385 vtkCamera* camera = myRenderer->GetActiveCamera();
386 camera->SetPosition(0,1,0);
387 camera->SetViewUp(0,0,1);
388 camera->SetFocalPoint(0,0,0);
392 //----------------------------------------------------------------------------
397 int aTrihedronIsVisible = isTrihedronDisplayed();
398 myTrihedron->SetVisibility( VTKViewer_Trihedron::eOnlyLineOn );
399 ::ResetCamera(myRenderer,true);
400 vtkCamera* aCamera = myRenderer->GetActiveCamera();
401 aCamera->SetPosition(1,-1,1);
402 aCamera->SetViewUp(0,0,1);
403 ::ResetCamera(myRenderer,true);
404 if(aTrihedronIsVisible) myTrihedron->VisibilityOn();
405 else myTrihedron->VisibilityOff();
406 static float aCoeff = 3.0;
407 aCamera->SetParallelScale(aCoeff*aCamera->GetParallelScale());
411 //----------------------------------------------------------------------------
416 myRWInteractor->GetSInteractorStyle()->ViewFitAll();
420 //----------------------------------------------------------------------------
425 QApplication::setOverrideCursor( Qt::waitCursor );
426 QPixmap px = QPixmap::grabWindow(myRenderWindow->winId());
427 QApplication::restoreOverrideCursor();
429 SUIT_Application* app = getViewManager()->study()->application();
431 QString aFileName = app->getFileName( false, QString::null, tr("VTK_IMAGE_FILES"), tr("INF_APP_DUMP_VIEW"), 0 );
433 if ( !aFileName.isNull() ) {
434 QApplication::setOverrideCursor( Qt::waitCursor );
435 QString fmt = SUIT_Tools::extension( aFileName ).upper();
437 fmt = QString("BMP"); // default format
440 bool bOk = px.save(aFileName, fmt.latin1());
441 QApplication::restoreOverrideCursor();
443 SUIT_MessageBox::error1(this, tr("ERROR"), tr("ERR_DOC_CANT_SAVE_FILE"), tr("BUT_OK"));
448 //----------------------------------------------------------------
451 ::onSelectionChanged()
455 const SALOME_ListIO& aListIO = mySelector->StoredIObjects();
456 SALOME_ListIteratorOfListIO anIter(aListIO);
457 for(; anIter.More(); anIter.Next()){
458 highlight(anIter.Value(),true,!anIter.More());
461 emit selectionChanged();
464 //----------------------------------------------------------------
467 ::SetSelectionMode(Selection_Mode theMode)
469 mySelector->SetSelectionMode(theMode);
470 myRWInteractor->SetSelectionMode(theMode);
473 //----------------------------------------------------------------
476 ::SelectionMode() const
478 return mySelector->SelectionMode();
481 //----------------------------------------------------------------
486 myRWInteractor->unHighlightAll();
489 //----------------------------------------------------------------
492 ::highlight( const Handle(SALOME_InteractiveObject)& theIO,
496 myRWInteractor->highlight(theIO, theIsHighlight, theIsUpdate);
498 if(mySelector->HasIndex(theIO) && theIO->hasEntry()){
499 TColStd_IndexedMapOfInteger aMapIndex;
500 mySelector->GetIndex(theIO,aMapIndex);
502 const char* anEntry = theIO->getEntry();
503 vtkActorCollection* aCollection = myRenderer->GetActors();
504 if(SALOME_Actor* anActor = Find<SALOME_Actor>(aCollection,TIsSameEntry<SALOME_Actor>(anEntry))){
505 switch (mySelector->SelectionMode()) {
507 myRWInteractor->highlightPoint(aMapIndex,anActor,theIsHighlight,theIsUpdate);
509 case EdgeOfCellSelection:
510 myRWInteractor->highlightEdge(aMapIndex,anActor,theIsHighlight,theIsUpdate);
515 case VolumeSelection:
516 myRWInteractor->highlightCell(aMapIndex,anActor,theIsHighlight,theIsUpdate);
521 myRWInteractor->unHighlightSubSelection();
525 //----------------------------------------------------------------
528 ::isInViewer( const Handle(SALOME_InteractiveObject)& theIO )
530 return myRWInteractor->isInViewer( theIO );
533 //----------------------------------------------------------------
536 ::isVisible( const Handle(SALOME_InteractiveObject)& theIO )
538 return myRWInteractor->isVisible( theIO );
541 //----------------------------------------------------------------------------
544 ::setBackgroundColor( const QColor& color )
547 myRenderer->SetBackground( color.red()/255., color.green()/255., color.blue()/255. );
550 //----------------------------------------------------------------------------
553 ::backgroundColor() const
557 myRenderer->GetBackground( backint );
558 return QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255));
560 return SUIT_ViewWindow::backgroundColor();
563 //----------------------------------------------------------------------------
566 ::Repaint(bool theUpdateTrihedron)
568 if (theUpdateTrihedron)
570 myRenderWindow->update();
573 //----------------------------------------------------------------------------
576 ::GetScale( double theScale[3] )
578 myTransform->GetScale( theScale );
581 //----------------------------------------------------------------------------
584 ::SetScale( double theScale[3] )
586 myTransform->SetScale( theScale[0], theScale[1], theScale[2] );
587 myRWInteractor->Render();
591 //----------------------------------------------------------------------------
594 ::isTrihedronDisplayed()
596 return myTrihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
599 //----------------------------------------------------------------------------
607 if(isTrihedronDisplayed())
608 myTrihedron->VisibilityOff();
610 myTrihedron->VisibilityOn();
615 //----------------------------------------------------------------------------
618 ::ComputeTrihedronSize( double& theNewSize, double& theSize )
620 // calculating diagonal of visible props of the renderer
622 myTrihedron->VisibilityOff();
624 if ( ::ComputeVisiblePropBounds( myRenderer, aBndBox ) == 0 ) {
625 aBndBox[ 1 ] = aBndBox[ 3 ] = aBndBox[ 5 ] = 100;
626 aBndBox[ 0 ] = aBndBox[ 2 ] = aBndBox[ 4 ] = 0;
629 myTrihedron->VisibilityOn();
631 static bool aCalcByDiag = false;
633 aLength = sqrt( ( aBndBox[1]-aBndBox[0])*(aBndBox[1]-aBndBox[0] )+
634 ( aBndBox[3]-aBndBox[2])*(aBndBox[3]-aBndBox[2] )+
635 ( aBndBox[5]-aBndBox[4])*(aBndBox[5]-aBndBox[4] ) );
637 aLength = aBndBox[ 1 ]-aBndBox[ 0 ];
638 aLength = max( ( aBndBox[ 3 ] - aBndBox[ 2 ] ),aLength );
639 aLength = max( ( aBndBox[ 5 ] - aBndBox[ 4 ] ),aLength );
642 static float aSizeInPercents = 105;
643 //QString aSetting = QAD_CONFIG->getSetting( "Viewer:TrihedronSize" );
644 //if ( !aSetting.isEmpty() )
645 // aSizeInPercents = aSetting.toFloat();
647 static float EPS_SIZE = 5.0E-3;
648 theSize = myTrihedron->GetSize();
649 theNewSize = aLength * aSizeInPercents / 100.0;
651 // if the new trihedron size have sufficient difference, then apply the value
652 return fabs( theNewSize - theSize) > theSize * EPS_SIZE ||
653 fabs( theNewSize-theSize ) > theNewSize * EPS_SIZE;
656 //----------------------------------------------------------------------------
659 ::GetTrihedronSize() const
661 return myTrihedron->GetSize();
664 //----------------------------------------------------------------------------
667 ::AdjustTrihedrons( const bool theIsForcedUpdate )
669 if ( !isTrihedronDisplayed() && !theIsForcedUpdate )
672 int aVisibleNum = myTrihedron->GetVisibleActorCount( myRenderer );
673 if ( aVisibleNum || theIsForcedUpdate ) {
674 // if the new trihedron size have sufficient difference, then apply the value
675 double aNewSize = 100, anOldSize;
676 if ( ComputeTrihedronSize( aNewSize, anOldSize ) || theIsForcedUpdate ) {
677 myTrihedron->SetSize( aNewSize );
678 // itearte throuh displayed objects and set size if necessary
680 vtkActorCollection* anActors = getRenderer()->GetActors();
681 anActors->InitTraversal();
682 while( vtkActor* anActor = anActors->GetNextActor() ) {
683 if( SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast( anActor ) ) {
684 if ( aSActor->IsResizable() )
685 aSActor->SetSize( 0.5 * aNewSize );
691 ::ResetCameraClippingRange(myRenderer);
694 //----------------------------------------------------------------------------
697 ::onAdjustTrihedron()
699 AdjustTrihedrons( false );
702 #define INCREMENT_FOR_OP 10
704 //=======================================================================
706 // Purpose : Performs incremental panning to the left
707 //=======================================================================
712 myRWInteractor->GetSInteractorStyle()->IncrementalPan( -INCREMENT_FOR_OP, 0 );
715 //=======================================================================
717 // Purpose : Performs incremental panning to the right
718 //=======================================================================
723 myRWInteractor->GetSInteractorStyle()->IncrementalPan( INCREMENT_FOR_OP, 0 );
726 //=======================================================================
728 // Purpose : Performs incremental panning to the top
729 //=======================================================================
734 myRWInteractor->GetSInteractorStyle()->IncrementalPan( 0, INCREMENT_FOR_OP );
737 //=======================================================================
739 // Purpose : Performs incremental panning to the bottom
740 //=======================================================================
745 myRWInteractor->GetSInteractorStyle()->IncrementalPan( 0, -INCREMENT_FOR_OP );
748 //=======================================================================
750 // Purpose : Performs incremental zooming in
751 //=======================================================================
756 myRWInteractor->GetSInteractorStyle()->IncrementalZoom( INCREMENT_FOR_OP );
759 //=======================================================================
761 // Purpose : Performs incremental zooming out
762 //=======================================================================
767 myRWInteractor->GetSInteractorStyle()->IncrementalZoom( -INCREMENT_FOR_OP );
770 //=======================================================================
771 // name : onRotateLeft
772 // Purpose : Performs incremental rotating to the left
773 //=======================================================================
778 myRWInteractor->GetSInteractorStyle()->IncrementalRotate( -INCREMENT_FOR_OP, 0 );
781 //=======================================================================
782 // name : onRotateRight
783 // Purpose : Performs incremental rotating to the right
784 //=======================================================================
789 myRWInteractor->GetSInteractorStyle()->IncrementalRotate( INCREMENT_FOR_OP, 0 );
792 //=======================================================================
794 // Purpose : Performs incremental rotating to the top
795 //=======================================================================
800 myRWInteractor->GetSInteractorStyle()->IncrementalRotate( 0, -INCREMENT_FOR_OP );
803 //=======================================================================
806 ::onKeyPressed(QKeyEvent* event)
808 emit keyPressed( this, event );
811 //=======================================================================
814 ::onKeyReleased(QKeyEvent* event)
816 emit keyReleased( this, event );
819 //=======================================================================
822 ::onMousePressed(QMouseEvent* event)
824 emit mousePressed(this, event);
827 //=======================================================================
830 ::onMouseReleased(QMouseEvent* event)
832 emit mouseReleased( this, event );
835 //=======================================================================
838 ::onMouseMoving(QMouseEvent* event)
840 emit mouseMoving( this, event );
843 //=======================================================================
846 ::onMouseDoubleClicked( QMouseEvent* event )
848 emit mouseDoubleClicked( this, event );
851 //=======================================================================
852 // name : onRotateDown
853 // Purpose : Performs incremental rotating to the bottom
854 //=======================================================================
859 myRWInteractor->GetSInteractorStyle()->IncrementalRotate( 0, INCREMENT_FOR_OP );
862 //----------------------------------------------------------------------------
865 ::InsertActor( SALOME_Actor* theActor, bool theMoveInternalActors )
867 theActor->AddToRender(myRenderer);
868 theActor->SetTransform(myTransform);
869 if(theMoveInternalActors)
870 myRWInteractor->MoveInternalActors();
873 //----------------------------------------------------------------------------
876 ::AddActor( SALOME_Actor* theActor, bool theUpdate /*=false*/ )
878 InsertActor(theActor);
883 //----------------------------------------------------------------------------
886 ::RemoveActor( SALOME_Actor* theActor, bool theUpdate /*=false*/ )
888 theActor->RemoveFromRender(myRenderer);
893 //----------------------------------------------------------------------------
896 ::MoveActor( SALOME_Actor* theActor)
898 RemoveActor(theActor);
899 InsertActor(theActor,true);