SALOME_Actor.h \
SVTK_CubeAxesActor2D.h \
SVTK_Functor.h \
+ SVTK_View.h \
SVTK_ViewManager.h \
SVTK_ViewModel.h \
SVTK_ViewWindow.h \
SALOME_Actor.cxx \
SVTK_CubeAxesActor2D.cxx \
SVTK_Trihedron.cxx \
+ SVTK_View.cxx \
SVTK_ViewManager.cxx \
SVTK_ViewModel.cxx \
SVTK_ViewWindow.cxx \
LIB_MOC = SVTK_RenderWindowInteractor.h \
SVTK_InteractorStyle.h \
SVTK_RenderWindow.h \
+ SVTK_View.h \
SVTK_ViewWindow.h \
SVTK_ViewModel.h \
SVTK_ViewManager.h
SVTK_InteractorStyle
::OnMouseMove()
{
- //cout << "void SVTK_InteractorStyle::OnMouseMove()" << endl;
+ //cout << "SVTK_InteractorStyle::OnMouseMove" << endl;
int x, y;
this->Interactor->GetEventPosition( x, y );
SVTK_InteractorStyle
::OnLeftButtonDown()
{
- //cout << "void SVTK_InteractorStyle::OnLeftButtonDown()" << endl;
+ //cout << "SVTK_InteractorStyle::OnLeftButtonDown" << endl;
int x, y;
this->Interactor->GetEventPosition( x, y );
SVTK_InteractorStyle
::OnLeftButtonUp()
{
- //cout << "void SVTK_InteractorStyle::OnLeftButtonUp()" << endl;
+ //cout << "SVTK_InteractorStyle::OnLeftButtonUp" << endl;
int x, y;
this->Interactor->GetEventPosition( x, y );
SVTK_InteractorStyle
::OnMiddleButtonDown()
{
- //cout << "void SVTK_InteractorStyle::OnMiddleButtonDown()" << endl;
+ //cout << "SVTK_InteractorStyle::OnMiddleButtonDown" << endl;
int x, y;
this->Interactor->GetEventPosition( x, y );
SVTK_InteractorStyle
::OnMiddleButtonUp()
{
- //cout << "void SVTK_InteractorStyle::OnMiddleButtonUp()" << endl;
+ //cout << "SVTK_InteractorStyle::OnMiddleButtonUp" << endl;
int x, y;
this->Interactor->GetEventPosition( x, y );
SVTK_InteractorStyle
::OnRightButtonDown()
{
- //cout << "void SVTK_InteractorStyle::OnRightButtonDown()" << endl;
+ //cout << "SVTK_InteractorStyle::OnRightButtonDown" << endl;
int x, y;
this->Interactor->GetEventPosition( x, y );
SVTK_InteractorStyle
::OnRightButtonUp()
{
- //cout << "void SVTK_InteractorStyle::OnRightButtonUp()" << endl;
+ //cout << "SVTK_InteractorStyle::OnRightButtonUp" << endl;
int x, y;
this->Interactor->GetEventPosition( x, y );
this->OnRightButtonUp( this->Interactor->GetControlKey(),
this->Interactor->GetShiftKey(),
x, y );
- /*
- if( State == VTK_INTERACTOR_STYLE_CAMERA_NONE )
- {
- QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
- event->pos(), event->globalPos(),
- event->state() );
- emit contextMenuRequested( &aEvent );
- }
- */
}
class SVTK_EXPORT SVTK_InteractorStyle : public QObject,
public vtkInteractorStyle
{
- Q_OBJECT;
+ Q_OBJECT
public:
// Description:
#include "SVTK_RenderWindow.h"
+#include "SVTK_Trihedron.h"
+#include "SVTK_CubeAxesActor2D.h"
+#include "SALOME_Actor.h"
-#include <qcolordialog.h>
-#include <qpopupmenu.h>
+#include "VTKViewer_Transform.h"
+#include "VTKViewer_Utilities.h"
+
+#include "QtxAction.h"
+
+#include "SUIT_Session.h"
+#include "SUIT_ToolButton.h"
+#include "SUIT_MessageBox.h"
+
+#include "SUIT_Tools.h"
+#include "SUIT_ResourceMgr.h"
#include <stdlib.h>
#include <math.h>
+#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRendererCollection.h>
+#include <vtkTextProperty.h>
#include <vtkCamera.h>
#ifndef WNT
#include <vtkXOpenGLRenderWindow.h>
//==========================================================
SVTK_RenderWindow
::SVTK_RenderWindow(QWidget* parent, const char* name) :
- QWidget(parent, name,
+ QMainWindow(parent, name,
Qt::WStyle_NoBorder | Qt::WDestructiveClose |
- Qt::WResizeNoErase | Qt::WRepaintNoErase)
+ Qt::WResizeNoErase | Qt::WRepaintNoErase),
+ myTrihedronSize( 100 )
{
- myRW = vtkRenderWindow::New();
+ myRenderWindow = vtkRenderWindow::New();
#ifndef WNT
- myRW->SetDisplayId((void*)x11Display());
+ myRenderWindow->SetDisplayId((void*)x11Display());
#endif
- myRW->SetWindowId((void*)winId());
- myRW->DoubleBufferOn();
+ myRenderWindow->SetWindowId((void*)winId());
+ myRenderWindow->DoubleBufferOn();
+ //myRenderWindow->DebugOn();
setMouseTracking(true);
+
+ myRenderer = vtkRenderer::New();
+ myTransform = VTKViewer_Transform::New();
+ myTrihedron = SVTK_Trihedron::New();
+ myCubeAxes = SVTK_CubeAxesActor2D::New();
+
+ myTrihedron->AddToRender( myRenderer );
+ myRenderer->AddProp(myCubeAxes);
+
+ myRenderWindow->AddRenderer( myRenderer );
+ myRenderer->GetActiveCamera()->ParallelProjectionOn();
+ myRenderer->LightFollowCameraOn();
+ myRenderer->TwoSidedLightingOn();
+
+ // Set BackgroundColor
+ QString BgrColorRed = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorRed");
+ QString BgrColorGreen = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorGreen");
+ QString BgrColorBlue = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorBlue");
+
+ if( !BgrColorRed.isEmpty() && !BgrColorGreen.isEmpty() && !BgrColorBlue.isEmpty() )
+ myRenderer->SetBackground( BgrColorRed.toInt()/255., BgrColorGreen.toInt()/255., BgrColorBlue.toInt()/255. );
+ else
+ myRenderer->SetBackground( 0, 0, 0 );
+
+ vtkTextProperty* tprop = vtkTextProperty::New();
+ tprop->SetColor(1, 1, 1);
+ tprop->ShadowOn();
+
+ float bnd[6];
+ bnd[0] = bnd[2] = bnd[4] = 0;
+ bnd[1] = bnd[3] = bnd[5] = myTrihedron->GetSize();
+ myCubeAxes->SetLabelFormat("%6.4g");
+ myCubeAxes->SetBounds(bnd);
+ myCubeAxes->SetCamera(myRenderer->GetActiveCamera());
+ myCubeAxes->SetFlyModeToOuterEdges(); // ENK remarks: it must bee
+ myCubeAxes->SetFontFactor(0.8);
+ myCubeAxes->SetAxisTitleTextProperty(tprop);
+ myCubeAxes->SetAxisLabelTextProperty(tprop);
+ myCubeAxes->SetCornerOffset(0);
+ myCubeAxes->SetScaling(0);
+ myCubeAxes->SetNumberOfLabels(5);
+ myCubeAxes->VisibilityOff();
+ myCubeAxes->SetTransform(myTransform);
+ tprop->Delete();
+
+ myToolBar = new QToolBar(this);
+ myToolBar->setCloseMode(QDockWindow::Undocked);
+ myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
+
+ createActions();
+ createToolBar();
}
//==========================================================
SVTK_RenderWindow
::~SVTK_RenderWindow()
{
- myRW->Delete();
+ myRenderWindow->Delete();
+
+ myTransform->Delete();
+
+ //m_RW->Delete() ;
+ myRenderer->RemoveAllProps();
+ //m_Renderer->Delete();
+ myTrihedron->Delete();
+ myCubeAxes->Delete();
}
//==========================================================
void
SVTK_RenderWindow
-::paintEvent(QPaintEvent* theEvent)
+::createActions()
{
- myRW->Render();
+ if (!myActionsMap.isEmpty()) return;
+
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+
+ QtxAction* aAction;
+
+ // Dump view
+ aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
+ tr( "MNU_DUMP_VIEW" ), 0, this);
+ aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onDumpView()));
+ myActionsMap[ DumpId ] = aAction;
+
+ // FitAll
+ aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
+ tr( "MNU_FITALL" ), 0, this);
+ aAction->setStatusTip(tr("DSC_FITALL"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onFitAll()));
+ myActionsMap[ FitAllId ] = aAction;
+
+ // FitRect
+ aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
+ tr( "MNU_FITRECT" ), 0, this);
+ aAction->setStatusTip(tr("DSC_FITRECT"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
+ myActionsMap[ FitRectId ] = aAction;
+
+ // Zoom
+ aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
+ tr( "MNU_ZOOM_VIEW" ), 0, this);
+ aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(activateZoom()));
+ myActionsMap[ ZoomId ] = aAction;
+
+ // Panning
+ aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
+ tr( "MNU_PAN_VIEW" ), 0, this);
+ aAction->setStatusTip(tr("DSC_PAN_VIEW"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(activatePanning()));
+ myActionsMap[ PanId ] = aAction;
+
+ // Global Panning
+ aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
+ tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
+ aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
+ myActionsMap[ GlobalPanId ] = aAction;
+
+ // Rotation
+ aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
+ tr( "MNU_ROTATE_VIEW" ), 0, this);
+ aAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(activateRotation()));
+ myActionsMap[ RotationId ] = aAction;
+
+ // Projections
+ aAction = new QtxAction(tr("MNU_FRONT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
+ tr( "MNU_FRONT_VIEW" ), 0, this);
+ aAction->setStatusTip(tr("DSC_FRONT_VIEW"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onFrontView()));
+ myActionsMap[ FrontId ] = aAction;
+
+ aAction = new QtxAction(tr("MNU_BACK_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
+ tr( "MNU_BACK_VIEW" ), 0, this);
+ aAction->setStatusTip(tr("DSC_BACK_VIEW"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onBackView()));
+ myActionsMap[ BackId ] = aAction;
+
+ aAction = new QtxAction(tr("MNU_TOP_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
+ tr( "MNU_TOP_VIEW" ), 0, this);
+ aAction->setStatusTip(tr("DSC_TOP_VIEW"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onTopView()));
+ myActionsMap[ TopId ] = aAction;
+
+ aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
+ tr( "MNU_BOTTOM_VIEW" ), 0, this);
+ aAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onBottomView()));
+ myActionsMap[ BottomId ] = aAction;
+
+ aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
+ tr( "MNU_LEFT_VIEW" ), 0, this);
+ aAction->setStatusTip(tr("DSC_LEFT_VIEW"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onLeftView()));
+ myActionsMap[ LeftId ] = aAction;
+
+ aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
+ tr( "MNU_RIGHT_VIEW" ), 0, this);
+ aAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onRightView()));
+ myActionsMap[ RightId ] = aAction;
+
+ // Reset
+ aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
+ tr( "MNU_RESET_VIEW" ), 0, this);
+ aAction->setStatusTip(tr("DSC_RESET_VIEW"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onResetView()));
+ myActionsMap[ ResetId ] = aAction;
+
+ // onViewTrihedron: Shows - Hides Trihedron
+ aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
+ tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
+ aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onViewTrihedron()));
+ myActionsMap[ ViewTrihedronId ] = aAction;
}
//==========================================================
void
SVTK_RenderWindow
-::resizeEvent(QResizeEvent* theEvent)
-{
- int aWidth = myRW->GetSize()[0], aHeight = myRW->GetSize()[1];
- if(vtkRenderWindowInteractor* aRWI = myRW->GetInteractor())
- aRWI->UpdateSize(width(), height());
- if(aWidth != width() || aHeight != height()){
- vtkRendererCollection * aRenderers = myRW->GetRenderers();
- aRenderers->InitTraversal();
- double aCoeff = 1.0;
- if(vtkRenderer *aRenderer = aRenderers->GetNextItem()){
- vtkCamera *aCamera = aRenderer->GetActiveCamera();
- double aScale = aCamera->GetParallelScale();
- if((aWidth - width())*(aHeight - height()) > 0)
- aCoeff = sqrt(double(aWidth)/double(width())*double(height())/double(aHeight));
- else
- aCoeff = double(aWidth)/double(width());
- aCamera->SetParallelScale(aScale*aCoeff);
- }
+::createToolBar()
+{
+ myActionsMap[DumpId]->addTo(myToolBar);
+ myActionsMap[ViewTrihedronId]->addTo(myToolBar);
+
+ SUIT_ToolButton* aScaleBtn = new SUIT_ToolButton(myToolBar);
+ aScaleBtn->AddAction(myActionsMap[FitAllId]);
+ aScaleBtn->AddAction(myActionsMap[FitRectId]);
+ aScaleBtn->AddAction(myActionsMap[ZoomId]);
+
+ SUIT_ToolButton* aPanningBtn = new SUIT_ToolButton(myToolBar);
+ aPanningBtn->AddAction(myActionsMap[PanId]);
+ aPanningBtn->AddAction(myActionsMap[GlobalPanId]);
+
+ myActionsMap[RotationId]->addTo(myToolBar);
+
+ SUIT_ToolButton* aViewsBtn = new SUIT_ToolButton(myToolBar);
+ aViewsBtn->AddAction(myActionsMap[FrontId]);
+ aViewsBtn->AddAction(myActionsMap[BackId]);
+ aViewsBtn->AddAction(myActionsMap[TopId]);
+ aViewsBtn->AddAction(myActionsMap[BottomId]);
+ aViewsBtn->AddAction(myActionsMap[LeftId]);
+ aViewsBtn->AddAction(myActionsMap[RightId]);
+
+ myActionsMap[ResetId]->addTo(myToolBar);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindow
+::Repaint( bool theUpdateTrihedron )
+{
+ if( theUpdateTrihedron )
+ onAdjustTrihedron();
+
+ update();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindow
+::setBackgroundColor( const QColor& color )
+{
+ if( myRenderer )
+ myRenderer->SetBackground( color.red()/255., color.green()/255., color.blue()/255. );
+}
+
+//----------------------------------------------------------------------------
+QColor
+SVTK_RenderWindow
+::backgroundColor() const
+{
+ float backint[3];
+ if( myRenderer )
+ {
+ myRenderer->GetBackground( backint );
+ return QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255));
}
+ return QColor();
}
-//==========================================================
+//----------------------------------------------------------------------------
void
SVTK_RenderWindow
-::mouseMoveEvent(QMouseEvent* event)
+::GetScale( double theScale[3] )
{
- emit MouseMove(event) ;
+ myTransform->GetMatrixScale( theScale );
}
-//==========================================================
+//----------------------------------------------------------------------------
void
SVTK_RenderWindow
-::mousePressEvent(QMouseEvent* event)
+::SetScale( double theScale[3] )
{
- emit MouseButtonPressed( event );
+ myTransform->SetMatrixScale( theScale[0], theScale[1], theScale[2] );
+ //myRWInteractor->Render();
+ Repaint();
}
-//==========================================================
+//----------------------------------------------------------------------------
+bool
+SVTK_RenderWindow
+::isTrihedronDisplayed()
+{
+ return myTrihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
+}
+
+//----------------------------------------------------------------------------
+bool
+SVTK_RenderWindow
+::isCubeAxesDisplayed()
+{
+ return myCubeAxes->GetVisibility() == 1;
+}
+
+//----------------------------------------------------------------------------
void
SVTK_RenderWindow
-::mouseReleaseEvent( QMouseEvent *event )
+::activateZoom()
{
- emit MouseButtonReleased( event );
+ //myInteractorStyle->startZoom();
}
-//==========================================================
+//----------------------------------------------------------------------------
void
-SVTK_RenderWindow::mouseDoubleClickEvent( QMouseEvent* event )
+SVTK_RenderWindow
+::activatePanning()
{
- emit MouseDoubleClicked( event );
+ //myInteractorStyle->startPan();
}
-//==========================================================
+//----------------------------------------------------------------------------
void
SVTK_RenderWindow
-::keyPressEvent (QKeyEvent* event)
+::activateRotation()
{
- emit KeyPressed(event) ;
+ //myInteractorStyle->startRotate();
}
-//==========================================================
+//----------------------------------------------------------------------------
void
SVTK_RenderWindow
-::keyReleaseEvent (QKeyEvent * event)
+::activateGlobalPanning()
{
- emit KeyReleased(event) ;
+ //myInteractorStyle->startGlobalPan();
}
-//==========================================================
+//----------------------------------------------------------------------------
void
SVTK_RenderWindow
-::wheelEvent(QWheelEvent* event)
+::activateWindowFit()
{
- emit WheelMoved(event) ;
+ //myInteractorStyle->startFitArea();
}
-//==========================================================
+//----------------------------------------------------------------------------
void
SVTK_RenderWindow
-::onChangeBackgroundColor()
+::onFrontView()
{
- //float red, green, blue;
- float backint[3];
+ vtkCamera* camera = myRenderer->GetActiveCamera();
+ camera->SetPosition(1,0,0);
+ camera->SetViewUp(0,0,1);
+ camera->SetFocalPoint(0,0,0);
+ onFitAll();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindow
+::onBackView()
+{
+ vtkCamera* camera = myRenderer->GetActiveCamera();
+ camera->SetPosition(-1,0,0);
+ camera->SetViewUp(0,0,1);
+ camera->SetFocalPoint(0,0,0);
+ onFitAll();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindow
+::onTopView()
+{
+ vtkCamera* camera = myRenderer->GetActiveCamera();
+ camera->SetPosition(0,0,1);
+ camera->SetViewUp(0,1,0);
+ camera->SetFocalPoint(0,0,0);
+ onFitAll();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindow
+::onBottomView()
+{
+ vtkCamera* camera = myRenderer->GetActiveCamera();
+ camera->SetPosition(0,0,-1);
+ camera->SetViewUp(0,1,0);
+ camera->SetFocalPoint(0,0,0);
+ onFitAll();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindow
+::onLeftView()
+{
+ vtkCamera* camera = myRenderer->GetActiveCamera();
+ camera->SetPosition(0,-1,0);
+ camera->SetViewUp(0,0,1);
+ camera->SetFocalPoint(0,0,0);
+ onFitAll();
+}
- vtkRendererCollection * theRenderers = myRW->GetRenderers();
- theRenderers->InitTraversal();
- vtkRenderer * theRenderer = theRenderers->GetNextItem();
- theRenderer->GetBackground(backint);
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindow
+::onRightView()
+{
+ vtkCamera* camera = myRenderer->GetActiveCamera();
+ camera->SetPosition(0,1,0);
+ camera->SetViewUp(0,0,1);
+ camera->SetFocalPoint(0,0,0);
+ onFitAll();
+}
- QColor selColor = QColorDialog::getColor ( QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255)), NULL );
- if ( selColor.isValid() ) {
- theRenderer->SetBackground( selColor.red()/255., selColor.green()/255., selColor.blue()/255. );
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindow
+::onResetView()
+{
+ int aTrihedronIsVisible = isTrihedronDisplayed();
+ int aCubeAxesIsVisible = isCubeAxesDisplayed();
+
+ myTrihedron->SetVisibility( VTKViewer_Trihedron::eOnlyLineOn );
+ myCubeAxes->SetVisibility(0);
+
+ ::ResetCamera(myRenderer,true);
+ vtkCamera* aCamera = myRenderer->GetActiveCamera();
+ aCamera->SetPosition(1,-1,1);
+ aCamera->SetViewUp(0,0,1);
+ ::ResetCamera(myRenderer,true);
+
+ if (aTrihedronIsVisible) myTrihedron->VisibilityOn();
+ else myTrihedron->VisibilityOff();
+
+ if (aCubeAxesIsVisible) myCubeAxes->VisibilityOn();
+ else myCubeAxes->VisibilityOff();
+
+ static float aCoeff = 3.0;
+ aCamera->SetParallelScale(aCoeff*aCamera->GetParallelScale());
+ Repaint();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindow
+::onFitAll()
+{
+ int aTrihedronWasVisible = false;
+ int aCubeAxesWasVisible = false;
+ if (myTrihedron) {
+ aTrihedronWasVisible = isTrihedronDisplayed();
+ if (aTrihedronWasVisible)
+ myTrihedron->VisibilityOff();
}
+
+ if (myCubeAxes) {
+ aCubeAxesWasVisible = isCubeAxesDisplayed();
+ if (aCubeAxesWasVisible)
+ myCubeAxes->VisibilityOff();
+ }
+
+ if (myTrihedron->GetVisibleActorCount(myRenderer)) {
+ myTrihedron->VisibilityOff();
+ myCubeAxes->VisibilityOff();
+ ::ResetCamera(myRenderer);
+ } else {
+ myTrihedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn);
+ myCubeAxes->SetVisibility(2);
+ ::ResetCamera(myRenderer,true);
+ }
+
+ if (aTrihedronWasVisible)
+ myTrihedron->VisibilityOn();
+ else
+ myTrihedron->VisibilityOff();
+
+ if (aCubeAxesWasVisible)
+ myCubeAxes->VisibilityOn();
+ else
+ myCubeAxes->VisibilityOff();
+
+ ::ResetCameraClippingRange(myRenderer);
+
+ Repaint();
}
-//==========================================================
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindow
+::onViewTrihedron()
+{
+ if(!myTrihedron)
+ return;
+
+ if(isTrihedronDisplayed())
+ myTrihedron->VisibilityOff();
+ else
+ myTrihedron->VisibilityOn();
+
+ Repaint();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindow
+::onViewCubeAxes()
+{
+ if(!myCubeAxes)
+ return;
+
+ if(isCubeAxesDisplayed())
+ myCubeAxes->VisibilityOff();
+ else
+ myCubeAxes->VisibilityOn();
+
+ Repaint();
+}
+//----------------------------------------------------------------------------
+int SVTK_RenderWindow::GetTrihedronSize() const
+{
+ return myTrihedronSize;
+}
+
+//----------------------------------------------------------------------------
+void SVTK_RenderWindow::SetTrihedronSize( const int sz )
+{
+ if ( myTrihedronSize == sz )
+ return;
+
+ myTrihedronSize = sz;
+ AdjustTrihedrons( true );
+}
+
+/*! If parameter theIsForcedUpdate is true, recalculate parameters for
+ * trihedron and cube axes, even if trihedron and cube axes is invisible.
+ */
void
SVTK_RenderWindow
-::contextMenuEvent ( QContextMenuEvent * e )
+::AdjustTrihedrons(const bool theIsForcedUpdate)
{
- if ( e->reason() != QContextMenuEvent::Mouse )
- emit contextMenuRequested( e );
+ if ((!isCubeAxesDisplayed() && !isTrihedronDisplayed()) && !theIsForcedUpdate)
+ return;
+
+ float bnd[ 6 ];
+ float newbnd[6];
+ newbnd[ 0 ] = newbnd[ 2 ] = newbnd[ 4 ] = VTK_LARGE_FLOAT;
+ newbnd[ 1 ] = newbnd[ 3 ] = newbnd[ 5 ] = -VTK_LARGE_FLOAT;
+
+ myCubeAxes->GetBounds(bnd);
+
+ int aVisibleNum = myTrihedron->GetVisibleActorCount( myRenderer );
+ //if (aVisibleNum || theIsForcedUpdate) {
+ if (aVisibleNum) {
+ // if the new trihedron size have sufficient difference, then apply the value
+ double aNewSize = 100, anOldSize=myTrihedron->GetSize();
+ bool aTDisplayed = isTrihedronDisplayed();
+ bool aCDisplayed = isCubeAxesDisplayed();
+ if(aTDisplayed) myTrihedron->VisibilityOff();
+ if(aCDisplayed) myCubeAxes->VisibilityOff();
+
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ QString aSetting = aResMgr->stringValue("Viewer:TrihedronSize", "105");
+ static float aSizeInPercents = aSetting.toFloat();
+
+ //bool isComputeTrihedronSize =
+ ::ComputeTrihedronSize(myRenderer, aNewSize, anOldSize, aSizeInPercents);
+
+ myTrihedron->SetSize( aNewSize );
+
+ // iterate through displayed objects and set size if necessary
+ vtkActorCollection* anActors = getRenderer()->GetActors();
+ anActors->InitTraversal();
+ while (vtkActor* anActor = anActors->GetNextActor())
+ {
+ if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast( anActor ))
+ {
+ if (aSActor->IsResizable())
+ aSActor->SetSize( 0.5 * aNewSize );
+ if (aSActor->GetVisibility() && !aSActor->IsInfinitive()) {
+ float *abounds = aSActor->GetBounds();
+ if (abounds[0] > -VTK_LARGE_FLOAT && abounds[1] < VTK_LARGE_FLOAT &&
+ abounds[2] > -VTK_LARGE_FLOAT && abounds[3] < VTK_LARGE_FLOAT &&
+ abounds[4] > -VTK_LARGE_FLOAT && abounds[5] < VTK_LARGE_FLOAT)
+ for (int i = 0; i < 5; i = i + 2) {
+ if (abounds[i] < newbnd[i]) newbnd[i] = abounds[i];
+ if (abounds[i+1] > newbnd[i+1]) newbnd[i+1] = abounds[i+1];
+ }
+ }
+ }
+ }
+ if (aTDisplayed) myTrihedron->VisibilityOn();
+ if (aCDisplayed) myCubeAxes->VisibilityOn();
+
+ } else {
+ double aSize = myTrihedron->GetSize();
+ newbnd[0] = newbnd[2] = newbnd[4] = 0;
+ newbnd[1] = newbnd[3] = newbnd[5] = aSize;
+ }
+
+ if (newbnd[0] < VTK_LARGE_FLOAT && newbnd[2] < VTK_LARGE_FLOAT && newbnd[4] < VTK_LARGE_FLOAT &&
+ newbnd[1] >-VTK_LARGE_FLOAT && newbnd[3] >-VTK_LARGE_FLOAT && newbnd[5] >-VTK_LARGE_FLOAT) {
+ for(int i=0;i<6;i++) bnd[i] = newbnd[i];
+ myCubeAxes->SetBounds(bnd);
+ }
+
+ myCubeAxes->SetBounds(bnd);
+
+ ::ResetCameraClippingRange(myRenderer);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindow
+::onAdjustTrihedron()
+{
+ AdjustTrihedrons( false );
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindow
+::onAdjustCubeAxes()
+{
+ AdjustTrihedrons(false);
}
#ifndef SVTK_RenderWindow_h
#define SVTK_RenderWindow_h
-#include <qwidget.h>
+#include <qmainwindow.h>
#include "SVTK.h"
+class VTKViewer_Trihedron;
+class VTKViewer_Transform;
+class SVTK_CubeAxesActor2D;
+
+class QtxAction;
+
+class vtkRenderer;
class vtkRenderWindow;
-class SVTK_EXPORT SVTK_RenderWindow : public QWidget
+class SVTK_EXPORT SVTK_RenderWindow : public QMainWindow
{
- Q_OBJECT;
+ Q_OBJECT
-public:
- SVTK_RenderWindow(QWidget *parent, const char *name);
+ public:
+ SVTK_RenderWindow( QWidget*, const char* );
virtual ~SVTK_RenderWindow() ;
- vtkRenderWindow* getRenderWindow() { return myRW; }
+ QToolBar* getToolBar() { return myToolBar; }
- protected:
- virtual void mouseMoveEvent( QMouseEvent* );
- virtual void mousePressEvent( QMouseEvent* );
- virtual void mouseReleaseEvent( QMouseEvent* );
- virtual void mouseDoubleClickEvent( QMouseEvent* );
- virtual void wheelEvent( QWheelEvent* );
- virtual void keyPressEvent( QKeyEvent* );
- virtual void keyReleaseEvent( QKeyEvent* );
- virtual void paintEvent( QPaintEvent* );
- virtual void resizeEvent( QResizeEvent* );
- virtual void onChangeBackgroundColor();
- virtual void contextMenuEvent( QContextMenuEvent * e );
-
- signals:
- void MouseMove( QMouseEvent* );
- void MouseButtonPressed( QMouseEvent* );
- void MouseButtonReleased( QMouseEvent* );
- void MouseDoubleClicked( QMouseEvent* );
- void WheelMoved( QWheelEvent* );
- void LeftButtonPressed(const QMouseEvent *event) ;
- void LeftButtonReleased(const QMouseEvent *event) ;
- void MiddleButtonPressed(const QMouseEvent *event) ;
- void MiddleButtonReleased(const QMouseEvent *event) ;
- void RightButtonPressed(const QMouseEvent *event) ;
- void RightButtonReleased(const QMouseEvent *event) ;
- void ButtonPressed(const QMouseEvent *event);
- void ButtonReleased(const QMouseEvent *event);
- void KeyPressed( QKeyEvent* );
- void KeyReleased( QKeyEvent* );
- void contextMenuRequested( QContextMenuEvent *e );
+ vtkRenderer* getRenderer() { return myRenderer;}
+ vtkRenderWindow* getRenderWindow() { return myRenderWindow; }
+
+ VTKViewer_Trihedron* GetTrihedron() { return myTrihedron; }
+ SVTK_CubeAxesActor2D* GetCubeAxes() { return myCubeAxes; }
+
+ int GetTrihedronSize() const;
+ void SetTrihedronSize( const int );
+ void AdjustTrihedrons( const bool forced );
+
+ bool isTrihedronDisplayed();
+ bool isCubeAxesDisplayed();
+
+ void Repaint( bool theUpdateTrihedron = true );
+
+ void setBackgroundColor( const QColor& );
+ QColor backgroundColor() const;
+
+ //apply existing transformation on adding SALOME_Actor
+ void SetScale( double theScale[3] );
+ void GetScale( double theScale[3] );
+ //void AddActor( VTKViewer_Actor*, bool update = false );
+ //void RemoveActor(VTKViewer_Actor*, bool update = false);
+
+ public slots:
+ virtual void activateZoom();
+ virtual void activateWindowFit();
+ virtual void activateRotation();
+ virtual void activatePanning();
+ virtual void activateGlobalPanning();
+
+ void onFrontView();
+ void onBackView();
+ void onTopView();
+ void onBottomView();
+ void onRightView();
+ void onLeftView();
+
+ void onResetView();
+ void onFitAll();
+
+ void onViewTrihedron();
+ void onViewCubeAxes();
+
+ void onAdjustTrihedron();
+ void onAdjustCubeAxes();
protected:
- vtkRenderWindow* myRW;
+ enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
+ FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, ViewTrihedronId };
+ typedef QMap<int, QtxAction*> ActionsMap;
+
+ void createActions();
+ void createToolBar();
+
+ vtkRenderer* myRenderer;
+ vtkRenderWindow* myRenderWindow;
+
+ VTKViewer_Transform* myTransform;
+ VTKViewer_Trihedron* myTrihedron;
+ int myTrihedronSize;
+ SVTK_CubeAxesActor2D* myCubeAxes;
+
+ QToolBar* myToolBar;
+ ActionsMap myActionsMap;
};
#endif
#include "SVTK_RenderWindowInteractor.h"
-#include "SVTK_RenderWindow.h"
-#include "SVTK_Selection.h"
-
#include "VTKViewer_Algorithm.h"
#include "SVTK_Functor.h"
#include "SALOME_Actor.h"
// VTK Includes
#include <vtkObjectFactory.h>
-#include <vtkPicker.h>
-#include <vtkCellPicker.h>
-#include <vtkPointPicker.h>
#include <vtkInteractorStyle.h>
#include <vtkRendererCollection.h>
#include <vtkRenderWindow.h>
+#include <vtkGenericRenderWindowInteractor.h>
#include <vtkCommand.h>
+#include <vtkPicker.h>
+#include <vtkCamera.h>
// QT Includes
-#include <qkeycode.h>
-
-#include <TColStd_IndexedMapOfInteger.hxx>
+#include <qcolordialog.h>
#include "utilities.h"
static int MYDEBUG = 0;
#endif
-
-SVTK_RenderWindowInteractor*
SVTK_RenderWindowInteractor
-::New()
+::SVTK_RenderWindowInteractor( QWidget* parent, const char* name ) :
+ SVTK_RenderWindow( parent, name )
{
- vtkObject *ret = vtkObjectFactory::CreateInstance("SVTK_RenderWindowInteractor") ;
- if( ret ) {
- return dynamic_cast<SVTK_RenderWindowInteractor *>(ret) ;
- }
- return new SVTK_RenderWindowInteractor;
-}
+ myInteractor = vtkGenericRenderWindowInteractor::New();
+ //myInteractor->DebugOn();
-SVTK_RenderWindowInteractor
-::SVTK_RenderWindowInteractor()
-{
- this->Enabled = 0 ;
- this->mTimer = new QTimer( this ) ;
+ myInteractor->SetRenderWindow( getRenderWindow() );
+
+ myInteractor->Disable();
+ mTimer = new QTimer( this ) ;
myDisplayMode = 0;
- myBasicPicker = vtkPicker::New();
- myCellPicker = vtkCellPicker::New();
- myPointPicker = vtkPointPicker::New();
connect(mTimer, SIGNAL(timeout()), this, SLOT(TimerFunc())) ;
}
delete mTimer ;
- myBasicPicker->Delete();
- myCellPicker->Delete();
- myPointPicker->Delete();
+ myInteractor->Delete();
}
//
// We cannot do much unless there is a render window
// associated with this interactor.
//
- if( ! RenderWindow ) {
- vtkErrorMacro(<< "SVTK_RenderWindowInteractor::Initialize(): No render window attached!") ;
+ if( !getRenderWindow() ) {
+ //vtkErrorMacro(<< "SVTK_RenderWindowInteractor::Initialize(): No render window attached!") ;
return ;
}
// it works. If the dynamic_cast does not work, we flag an error
// and get the hell out.
//
- vtkRenderWindow *aRenderWindow = dynamic_cast<vtkRenderWindow *>(RenderWindow) ;
- if( !aRenderWindow ) {
- vtkErrorMacro(<< "SVTK_RenderWindowInteractor::Initialize() can only handle VTKViewer_RenderWindow.") ;
+ //vtkRenderWindow *aRenderWindow = dynamic_cast<vtkRenderWindow *>(getRenderWindow());
+ if( !getRenderWindow() ) {
+ //vtkErrorMacro(<< "SVTK_RenderWindowInteractor::Initialize() can only handle VTKViewer_RenderWindow.") ;
return ;
}
// If the render window has zero size, then set it to a default
// value of 300x300.
//
- int* aSize = aRenderWindow->GetSize();
- this->Size[0] = ((aSize[0] > 0) ? aSize[0] : 300);
- this->Size[1] = ((aSize[1] > 0) ? aSize[1] : 300);
+ int* aSize = getRenderWindow()->GetSize();
+ myInteractor->SetSize( ((aSize[0] > 0) ? aSize[0] : 300), ((aSize[1] > 0) ? aSize[1] : 300) );
- this->SetPicker(myBasicPicker);
- //this->SetPicker(vtkPicker::New());
+ myInteractor->SetPicker(vtkPicker::New());
//SetSelectionTolerance();
//
- // Enable the interactor.
+ // The interactor has been initialized.
//
- this->Enable() ;
+ myInteractor->Initialize() ;
//
- // Start the rendering of the window.
+ // Enable the interactor.
//
- aRenderWindow->Start() ;
+ myInteractor->Enable() ;
//
- // The interactor has been initialized.
+ // Start the rendering of the window.
//
- this->Initialized = 1 ;
+ getRenderWindow()->Start() ;
return ;
}
// event loop. Only the QtApplication objects are
// allowed to do that.
//
- vtkErrorMacro(<<"SVTK_RenderWindowInteractor::Start() not allowed to start event loop.") ;
+ //vtkErrorMacro(<<"SVTK_RenderWindowInteractor::Start() not allowed to start event loop.") ;
return ;
}
::UpdateSize(int w, int h)
{
// if the size changed send this on to the RenderWindow
- if ((w != this->Size[0])||(h != this->Size[1])) {
- this->Size[0] = w;
- this->Size[1] = h;
- this->RenderWindow->SetSize(w,h);
+ if ((w != myInteractor->GetSize()[0])||(h != myInteractor->GetSize()[1])) {
+ myInteractor->SetSize( w, h );
+ getRenderWindow()->SetSize( w, h );
}
}
SVTK_RenderWindowInteractor
::TimerFunc()
{
- if( ! this->Enabled ) {
+ if( ! myInteractor->GetEnabled() ) {
return ;
}
- vtkInteractorStyle* aStyle = vtkInteractorStyle::SafeDownCast( InteractorStyle );
+ vtkInteractorStyle* aStyle = vtkInteractorStyle::SafeDownCast( myInteractor->GetInteractorStyle() );
aStyle->OnTimer();
- emit RenderWindowModified();
-}
-
-void
-SVTK_RenderWindowInteractor
-::MouseMove(const QMouseEvent *event)
-{
- if( ! this->Enabled ) {
- return ;
- }
-
- this->SetEventInformation( event->x(), event->y(),
- ( event->state() & ControlButton ),
- ( event->state() & ShiftButton ) );
-
- if( this->HasObserver( vtkCommand::MouseMoveEvent ) )
- this->InvokeEvent( vtkCommand::MouseMoveEvent, NULL );
-}
-
-void
-SVTK_RenderWindowInteractor
-::LeftButtonPressed(const QMouseEvent *event)
-{
- if( ! this->Enabled ) {
- return ;
- }
-
- this->SetEventInformation( event->x(), event->y(),
- ( event->state() & ControlButton ),
- ( event->state() & ShiftButton ) );
-
- if( this->HasObserver( vtkCommand::LeftButtonPressEvent ) )
- this->InvokeEvent( vtkCommand::LeftButtonPressEvent, NULL );
-}
-
-void
-SVTK_RenderWindowInteractor
-::LeftButtonReleased(const QMouseEvent *event) {
- if( ! this->Enabled ) {
- return ;
- }
-
- this->SetEventInformation( event->x(), event->y(),
- ( event->state() & ControlButton ),
- ( event->state() & ShiftButton ) );
-
- if( this->HasObserver( vtkCommand::LeftButtonReleaseEvent ) )
- this->InvokeEvent( vtkCommand::LeftButtonReleaseEvent, NULL );
-}
-
-void
-SVTK_RenderWindowInteractor
-::MiddleButtonPressed(const QMouseEvent *event)
-{
- if( ! this->Enabled ) {
- return ;
- }
-
- this->SetEventInformation( event->x(), event->y(),
- ( event->state() & ControlButton ),
- ( event->state() & ShiftButton ) );
-
- if( this->HasObserver( vtkCommand::MiddleButtonPressEvent ) )
- this->InvokeEvent( vtkCommand::MiddleButtonPressEvent, NULL );
-}
-
-void
-SVTK_RenderWindowInteractor
-::MiddleButtonReleased(const QMouseEvent *event)
-{
- if( ! this->Enabled ) {
- return ;
- }
-
- this->SetEventInformation( event->x(), event->y(),
- ( event->state() & ControlButton ),
- ( event->state() & ShiftButton ) );
-
- if( this->HasObserver( vtkCommand::MiddleButtonReleaseEvent ) )
- this->InvokeEvent( vtkCommand::MiddleButtonReleaseEvent, NULL );
-}
-
-void
-SVTK_RenderWindowInteractor
-::RightButtonPressed(const QMouseEvent *event)
-{
- if( ! this->Enabled ) {
- return ;
- }
-
- this->SetEventInformation( event->x(), event->y(),
- ( event->state() & ControlButton ),
- ( event->state() & ShiftButton ) );
-
- if( this->HasObserver( vtkCommand::RightButtonPressEvent ) )
- this->InvokeEvent( vtkCommand::RightButtonPressEvent, NULL );
-}
-
-void
-SVTK_RenderWindowInteractor
-::RightButtonReleased(const QMouseEvent *event)
-{
- if( ! this->Enabled ) {
- return ;
- }
-
- this->SetEventInformation( event->x(), event->y(),
- ( event->state() & ControlButton ),
- ( event->state() & ShiftButton ) );
-
- if( this->HasObserver( vtkCommand::RightButtonReleaseEvent ) )
- this->InvokeEvent( vtkCommand::RightButtonReleaseEvent, NULL );
-
- if(/*myInteractorStyle->GetState() == VTK_INTERACTOR_STYLE_CAMERA_NONE && */!( event->state() & KeyButtonMask )){
- QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
- event->pos(), event->globalPos(),
- event->state() );
- emit contextMenuRequested( &aEvent );
- }
-}
-
-void
-SVTK_RenderWindowInteractor
-::ButtonPressed(const QMouseEvent *event)
-{
- return ;
-}
-
-void
-SVTK_RenderWindowInteractor
-::ButtonReleased(const QMouseEvent *event)
-{
- return ;
+ update();
}
-
int
SVTK_RenderWindowInteractor
::GetDisplayMode()
ForEach<SALOME_Actor>(theCollection,
TSetFunction<SALOME_Actor,int>
(&SALOME_Actor::setDisplayMode,0));
- emit RenderWindowModified();
+ update();
}
void
ForEach<SALOME_Actor>(theCollection,
TSetFunction<SALOME_Actor,int>
(&SALOME_Actor::setDisplayMode,1));
- emit RenderWindowModified();
+ update();
}
SVTK_RenderWindowInteractor
::GetRenderer()
{
- vtkRendererCollection * theRenderers = this->RenderWindow->GetRenderers();
+ vtkRendererCollection * theRenderers = getRenderWindow()->GetRenderers();
theRenderers->InitTraversal();
return theRenderers->GetNextItem();
}
ForEach<SALOME_Actor>(GetRenderer()->GetActors(),
TErase());
- emit RenderWindowModified() ;
+ update();
}
void
using namespace VTK;
ForEach<SALOME_Actor>(aCollection,TSetVisibility<SALOME_Actor>(true));
- emit RenderWindowModified() ;
+ update();
}
void
SVTK_RenderWindowInteractor
-::Erase(SALOME_Actor* theActor, bool update)
+::Erase(SALOME_Actor* theActor, bool updateViewer)
{
TErase()(theActor);
- if(update)
- emit RenderWindowModified();
+ if(updateViewer)
+ update();
}
void
SVTK_RenderWindowInteractor
::Erase(const Handle(SALOME_InteractiveObject)& theIObject,
- bool update)
+ bool updateViewer)
{
using namespace VTK;
ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
TIsSameIObject<SALOME_Actor>(theIObject),
TErase());
- if(update)
- emit RenderWindowModified();
+ if(updateViewer)
+ update();
}
void
SVTK_RenderWindowInteractor
::Remove(const Handle(SALOME_InteractiveObject)& theIObject,
- bool update)
+ bool updateViewer)
{
vtkRenderer* aRen = GetRenderer();
{
GetRenderer()->RemoveProp( SActor );
if ( updateViewer )
- emit RenderWindowModified();
+ update();
}
}
}
if ( updateViewer )
- emit RenderWindowModified();
+ update();
}
}
void
SVTK_RenderWindowInteractor
-::Display(SALOME_Actor* theActor, bool update)
+::Display(SALOME_Actor* theActor, bool updateViewer)
{
GetRenderer()->AddActor(theActor);
theActor->SetVisibility(true);
- if(update)
- emit RenderWindowModified();
+ if(updateViewer)
+ update();
}
void
SVTK_RenderWindowInteractor
-::Display(const Handle(SALOME_InteractiveObject)& theIObject, bool update)
+::Display(const Handle(SALOME_InteractiveObject)& theIObject, bool updateViewer)
{
using namespace VTK;
ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
TIsSameIObject<SALOME_Actor>(theIObject),
TSetVisibility<SALOME_Actor>(true));
- if(update)
- emit RenderWindowModified() ;
+ if(updateViewer)
+ update();
}
-
-void
-SVTK_RenderWindowInteractor
-::KeyPressed(QKeyEvent *event)
-{}
-
struct TUpdateAction{
void operator()(vtkActor* theActor){
theActor->ApplyProperties();
aRen->ResetCamera();
- emit RenderWindowModified();
+ update();
}
//-----------------
TSetFunction<SALOME_Actor,const char*,QString>
(&SALOME_Actor::setName,theName.latin1()));
}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindowInteractor
+::mouseMoveEvent( QMouseEvent* event )
+{
+ //cout << "SVTK_RenderWindowInteractor::mouseMoveEvent" << endl;
+
+ myInteractor->SetEventInformation( event->x(), event->y(),
+ ( event->state() & ControlButton ),
+ ( event->state() & ShiftButton ) );
+
+ myInteractor->MouseMoveEvent();
+
+ //emit MouseMove( event ) ;
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindowInteractor
+::mousePressEvent( QMouseEvent* event )
+{
+ //cout << "SVTK_RenderWindowInteractor::mousePressEvent" << endl;
+
+ myInteractor->SetEventInformation( event->x(), event->y(),
+ ( event->state() & ControlButton ),
+ ( event->state() & ShiftButton ) );
+
+ if( event->button() & LeftButton )
+ myInteractor->LeftButtonPressEvent();
+ else if( event->button() & MidButton )
+ myInteractor->MiddleButtonPressEvent();
+ else if( event->button() & RightButton )
+ myInteractor->RightButtonPressEvent();
+
+ //emit MouseButtonPressed( event );
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindowInteractor
+::mouseReleaseEvent( QMouseEvent *event )
+{
+ //cout << "SVTK_RenderWindowInteractor::mouseReleaseEvent" << endl;
+
+ myInteractor->SetEventInformation( event->x(), event->y(),
+ ( event->state() & ControlButton ),
+ ( event->state() & ShiftButton ) );
+
+ if( event->button() & LeftButton )
+ myInteractor->LeftButtonReleaseEvent();
+ else if( event->button() & MidButton )
+ myInteractor->MiddleButtonReleaseEvent();
+ else if( event->button() & RightButton )
+ myInteractor->RightButtonReleaseEvent();
+
+ //emit MouseButtonReleased( event );
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindowInteractor
+::mouseDoubleClickEvent( QMouseEvent* event )
+{
+ //cout << "SVTK_RenderWindowInteractor::mouseDoubleClickEvent" << endl;
+
+ //emit MouseDoubleClicked( event );
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindowInteractor
+::keyPressEvent( QKeyEvent* event )
+{
+ //cout << "SVTK_RenderWindowInteractor::keyPressEvent" << endl;
+
+ myInteractor->SetKeyEventInformation( ( event->state() & ControlButton ),
+ ( event->state() & ShiftButton ),
+ 0 );
+
+ myInteractor->KeyPressEvent();
+
+ //emit KeyPressed(event) ;
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindowInteractor
+::keyReleaseEvent( QKeyEvent * event )
+{
+ //cout << "SVTK_RenderWindowInteractor::keyReleaseEvent" << endl;
+
+ myInteractor->SetKeyEventInformation( ( event->state() & ControlButton ),
+ ( event->state() & ShiftButton ),
+ 0 );
+
+ myInteractor->KeyReleaseEvent();
+
+ //emit KeyReleased(event) ;
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindowInteractor
+::wheelEvent( QWheelEvent* event )
+{
+ //cout << "SVTK_RenderWindowInteractor::wheelEvent" << endl;
+
+ //emit WheelMoved(event) ;
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindowInteractor
+::contextMenuEvent( QContextMenuEvent* event )
+{
+ //cout << "SVTK_RenderWindowInteractor::contextMenuEvent" << endl;
+
+ if( !( event->state() & KeyButtonMask ) )
+ emit contextMenuRequested( event );
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindowInteractor
+::paintEvent( QPaintEvent* theEvent )
+{
+ getRenderWindow()->Render();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindowInteractor
+::resizeEvent( QResizeEvent* theEvent )
+{
+ int aWidth = getRenderWindow()->GetSize()[0], aHeight = getRenderWindow()->GetSize()[1];
+
+ myInteractor->UpdateSize( width(), height() );
+
+ if( aWidth != width() || aHeight != height() )
+ {
+ vtkRendererCollection * aRenderers = getRenderWindow()->GetRenderers();
+ aRenderers->InitTraversal();
+ double aCoeff = 1.0;
+ if(vtkRenderer *aRenderer = aRenderers->GetNextItem())
+ {
+ vtkCamera *aCamera = aRenderer->GetActiveCamera();
+ double aScale = aCamera->GetParallelScale();
+ if((aWidth - width())*(aHeight - height()) > 0)
+ aCoeff = sqrt(double(aWidth)/double(width())*double(height())/double(aHeight));
+ else
+ aCoeff = double(aWidth)/double(width());
+ aCamera->SetParallelScale(aScale*aCoeff);
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindowInteractor
+::onChangeBackgroundColor()
+{
+ float backint[3];
+
+ vtkRendererCollection* theRenderers = getRenderWindow()->GetRenderers();
+ theRenderers->InitTraversal();
+ vtkRenderer* theRenderer = theRenderers->GetNextItem();
+ theRenderer->GetBackground(backint);
+
+ QColor selColor = QColorDialog::getColor ( QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255)), NULL );
+ if ( selColor.isValid() )
+ theRenderer->SetBackground( selColor.red()/255., selColor.green()/255., selColor.blue()/255. );
+}
#include "SVTK.h"
#include "SVTK_Selection.h"
+#include "SVTK_RenderWindow.h"
#include "SALOME_InteractiveObject.hxx"
// QT Includes
-#include <qobject.h>
#include <qtimer.h>
// VTK Includes
#include <vtkVersion.h>
-#include <vtkRenderWindowInteractor.h>
-// Open CASCADE Includes
-#include <TColStd_MapOfInteger.hxx>
-#include <TColStd_IndexedMapOfInteger.hxx>
-#include <TColStd_MapIteratorOfMapOfInteger.hxx>
-
-class vtkPicker;
-class vtkCellPicker;
-class vtkPointPicker;
class vtkActorCollection;
+class vtkGenericRenderWindowInteractor;
class SALOME_Actor;
-class SVTK_ViewWindow;
-class SVTK_RenderWindow;
-
// ------------------------------------------------------------
// :TRICKY: Fri Apr 21 22:19:27 2000 Pagey
// The Signal/Slot mechanism used by Qt requires that QObject
// Hence the order of the two classes QObject and vtkRenderWindowInteractor
// matters here. Be careful not to change it by accident.
// ------------------------------------------------------------
-class SVTK_EXPORT SVTK_RenderWindowInteractor: public QObject,
- public vtkRenderWindowInteractor
+class SVTK_EXPORT SVTK_RenderWindowInteractor: public SVTK_RenderWindow//, public vtkRenderWindowInteractor
{
- Q_OBJECT ;
- friend class SVTK_ViewWindow;
-public:
+ Q_OBJECT
- static SVTK_RenderWindowInteractor *New() ;
+public:
+ SVTK_RenderWindowInteractor( QWidget*, const char* );
+ ~SVTK_RenderWindowInteractor();
- vtkTypeMacro(SVTK_RenderWindowInteractor,vtkRenderWindowInteractor);
+ vtkGenericRenderWindowInteractor* getInteractor() { return myInteractor; }
// Description:
// Initializes the event handlers without an XtAppContext. This is
bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject);
bool isVisible( const Handle(SALOME_InteractiveObject)& IObject);
void rename(const Handle(SALOME_InteractiveObject)& IObject, QString newName);
- /*
- void SetSelectionMode(Selection_Mode mode);
- void SetSelectionProp(const double& theRed = 1,
- const double& theGreen = 1,
- const double& theBlue = 0,
- const int& theWidth = 5);
- void SetSelectionTolerance(const double& theTolNodes = 0.025,
- const double& theTolCell = 0.001);
- */
+
// Displaymode management
int GetDisplayMode();
void SetDisplayMode(int);
vtkRenderer* GetRenderer();
protected:
-
- SVTK_RenderWindowInteractor();
- ~SVTK_RenderWindowInteractor();
+ vtkGenericRenderWindowInteractor* myInteractor;
// Timer used during various mouse events to figure
// out mouse movements.
QTimer *mTimer ;
int myDisplayMode;
- vtkPicker* myBasicPicker;
- vtkCellPicker* myCellPicker;
- vtkPointPicker* myPointPicker;
// User for switching to stereo mode.
int PositionBeforeStereo[2];
- public slots:
- void MouseMove(const QMouseEvent *event) ;
- void LeftButtonPressed(const QMouseEvent *event) ;
- void LeftButtonReleased(const QMouseEvent *event) ;
- void MiddleButtonPressed(const QMouseEvent *event) ;
- void MiddleButtonReleased(const QMouseEvent *event) ;
- void RightButtonPressed(const QMouseEvent *event) ;
- void RightButtonReleased(const QMouseEvent *event) ;
- void ButtonPressed(const QMouseEvent *event) ;
- void ButtonReleased(const QMouseEvent *event) ;
- void KeyPressed(QKeyEvent *event) ;
+ protected:
+ virtual void mouseMoveEvent( QMouseEvent* );
+ virtual void mousePressEvent( QMouseEvent* );
+ virtual void mouseReleaseEvent( QMouseEvent* );
+ virtual void mouseDoubleClickEvent( QMouseEvent* );
+ virtual void wheelEvent( QWheelEvent* );
+ virtual void keyPressEvent( QKeyEvent* );
+ virtual void keyReleaseEvent( QKeyEvent* );
+ virtual void contextMenuEvent( QContextMenuEvent * e );
+
+ virtual void paintEvent( QPaintEvent* );
+ virtual void resizeEvent( QResizeEvent* );
+ virtual void onChangeBackgroundColor();
private slots:
// Not all of these slots are needed in VTK_MAJOR_VERSION=3,
void TimerFunc() ;
signals:
- void RenderWindowModified() ;
void contextMenuRequested( QContextMenuEvent *e );
- private:
- double myTolNodes;
- double myTolItems;
};
{
myInteractorStyle->IncrementalRotate( 0, INCREMENT_FOR_OP );
}
-/*
+
//----------------------------------------------------------------------------
void
SVTK_View
::InsertActor( VTKViewer_Actor* theActor, bool theMoveInternalActors )
{
- //cout << "SVTK_View::InsertActor" << endl;
theActor->AddToRender( getRenderer() );
//theActor->SetTransform(myTransform);
SVTK_View
::RemoveActor( VTKViewer_Actor* theActor, bool theUpdate )
{
- //cout << "SVTK_View::RemoveActor" << endl;
theActor->RemoveFromRender( getRenderer() );
if(theUpdate)
RemoveActor(theActor);
InsertActor(theActor,true);
}
-*/
+
/*
//----------------------------------------------------------------------------
QImage
void Repaint() { Repaint(true); }
//apply existing transformation on adding SALOME_Actor
- //void AddActor( VTKViewer_Actor*, bool update = false );
- //void RemoveActor(VTKViewer_Actor*, bool update = false);
+ void AddActor( VTKViewer_Actor*, bool update = false );
+ void RemoveActor(VTKViewer_Actor*, bool update = false);
void AdjustTrihedrons( const bool forced );
- //merge with V2_2_0_VISU_improvements:bool ComputeTrihedronSize( double& theNewSize,
- //merge with V2_2_0_VISU_improvements: double& theOldSize );
void SetSelectionProp(const double& theRed = 1,
const double& theGreen = 1,
#include "SVTK_Selection.h"
#include "SVTK_ViewModel.h"
#include "SVTK_ViewWindow.h"
+#include "SVTK_View.h"
#include "SVTK_Prs.h"
#include "SVTK_RenderWindowInteractor.h"
thePopup->insertSeparator();
SVTK_ViewWindow* aView = (SVTK_ViewWindow*)(myViewManager->getActiveView());
- if ( aView && !aView->getToolBar()->isVisible() )
- thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) );
+ //if ( aView && !aView->getToolBar()->isVisible() )
+ // thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) );
}
//==========================================================
void SVTK_Viewer::onMousePress(SUIT_ViewWindow* vw, QMouseEvent* event)
{
+ /*
if(SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(vw)){
- if(SVTK_RenderWindowInteractor* aRWI = aVW->getRWInteractor()){
+ if(SVTK_RenderWindowInteractor* aRWI = aVW->getView()){
switch(event->button()) {
case LeftButton:
aRWI->LeftButtonPressed(event) ;
}
}
}
+ */
}
//==========================================================
SVTK_Viewer
::onMouseMove(SUIT_ViewWindow* vw, QMouseEvent* event)
{
+ /*
if(SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(vw)){
- if(SVTK_RenderWindowInteractor* aRWI = aVW->getRWInteractor()){
+ if(SVTK_RenderWindowInteractor* aRWI = aVW->getView()){
aRWI->MouseMove( event );
}
}
+ */
}
//==========================================================
SVTK_Viewer
::onMouseRelease(SUIT_ViewWindow* vw, QMouseEvent* event)
{
+ /*
if(SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(vw)){
- if(SVTK_RenderWindowInteractor* aRWI = aVW->getRWInteractor()){
+ if(SVTK_RenderWindowInteractor* aRWI = aVW->getView()){
switch(event->button()) {
case LeftButton:
aRWI->LeftButtonReleased(event) ;
}
}
}
+ */
}
//==========================================================
SVTK_Viewer
::onShowToolbar()
{
+ /*
QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))
- aView->getToolBar()->show();
+ aView->getToolBar()->show();
+ */
}
//==========================================================
for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){
if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)){
- if(SVTK_RenderWindowInteractor* aRWI = aView->getRWInteractor()){
+ if(SVTK_RenderWindowInteractor* aRWI = aView->getView()){
aRWI->Display(anAct,false);
if(anAct->IsSetCamera()){
- vtkRenderer* aRenderer = aView->getRenderer();
+ vtkRenderer* aRenderer = aView->getView()->getRenderer();
anAct->SetCamera( aRenderer->GetActiveCamera() );
}
}
for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))
- if(SVTK_RenderWindowInteractor* aRWI = aView->getRWInteractor())
+ if(SVTK_RenderWindowInteractor* aRWI = aView->getView())
if ( forced )
aRWI->Remove(anAct,false);
else
for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){
if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)){
- vtkRenderer* aRenderer = aView->getRenderer();
+ vtkRenderer* aRenderer = aView->getView()->getRenderer();
vtkActorCollection* anActorCollection = aRenderer->GetActors();
anActorCollection->InitTraversal();
while(vtkActor* anActor = anActorCollection->GetNextActor()){
{
SVTK_Prs* prs = new SVTK_Prs();
if ( entry ) {
- vtkRenderer* rnr = ( (SVTK_ViewWindow*) getViewManager()->getActiveView() )->getRenderer();
+ vtkRenderer* rnr = ( (SVTK_ViewWindow*) getViewManager()->getActiveView() )->getView()->getRenderer();
vtkActorCollection* theActors = rnr->GetActors();
theActors->InitTraversal();
vtkActor* ac;
for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))
- if(SVTK_RenderWindowInteractor* aRWI = aView->getRWInteractor())
+ if(SVTK_RenderWindowInteractor* aRWI = aView->getView())
if(!aRWI->isVisible( io ))
return false;
return true;
for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))
- if(SVTK_RenderWindow* aRW = aView->getRenderWindow())
+ if(SVTK_RenderWindow* aRW = aView->getView())
aRW->update();
}
#include "SALOME_Actor.h"
#include <qapplication.h>
+#include <qsplitter.h>
+#include <qlayout.h>
#include <vtkTextProperty.h>
#include <vtkActorCollection.h>
#include "SUIT_Tools.h"
#include "SUIT_ResourceMgr.h"
-#include "VTKViewer_Transform.h"
#include "VTKViewer_Utilities.h"
#include "VTKViewer_CellRectPicker.h"
-#include "SVTK_Trihedron.h"
-#include "SVTK_CubeAxesActor2D.h"
+//#include "SVTK_View.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_ViewModel.h"
-#include "SVTK_RenderWindow.h"
#include "SVTK_RenderWindowInteractor.h"
#include "SVTK_InteractorStyle.h"
SVTK_ViewWindow
::SVTK_ViewWindow( SUIT_Desktop* theDesktop,
SVTK_Viewer* theModel)
- : SUIT_ViewWindow( theDesktop ),
- myTrihedronSize( 100 )
+ : SUIT_ViewWindow( theDesktop )
{
myModel = theModel;
mySelector = new SVTK_SelectorDef();
connect(this,SIGNAL(selectionChanged()),theModel,SLOT(onSelectionChanged()));
- myTransform = VTKViewer_Transform::New();
- myTrihedron = SVTK_Trihedron::New();
- myCubeAxes = SVTK_CubeAxesActor2D::New();
- myRenderer = vtkRenderer::New() ;
+ QWidget* aCentralWidget = new QWidget( this );
+ setCentralWidget( aCentralWidget );
+ QBoxLayout* aLayout = new QVBoxLayout( aCentralWidget );
+ aLayout->setAutoAdd( true );
+ QSplitter* aSplitter = new QSplitter( Qt::Vertical, aCentralWidget );
- myTrihedron->AddToRender( myRenderer );
- myRenderer->AddProp(myCubeAxes);
-
- myRenderWindow = new SVTK_RenderWindow( this, "RenderWindow" );
- setCentralWidget(myRenderWindow);
- myRenderWindow->setFocusPolicy( StrongFocus );
- myRenderWindow->setFocus();
-
- myRenderWindow->getRenderWindow()->AddRenderer( myRenderer );
-
- myRenderer->GetActiveCamera()->ParallelProjectionOn();
- myRenderer->LightFollowCameraOn();
- myRenderer->TwoSidedLightingOn();
-
- // Set BackgroundColor
- QString BgrColorRed = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorRed");
- QString BgrColorGreen = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorGreen");
- QString BgrColorBlue = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorBlue");
-
- if( !BgrColorRed.isEmpty() && !BgrColorGreen.isEmpty() && !BgrColorBlue.isEmpty() )
- myRenderer->SetBackground( BgrColorRed.toInt()/255., BgrColorGreen.toInt()/255., BgrColorBlue.toInt()/255. );
- else
- myRenderer->SetBackground( 0, 0, 0 );
-
// Create an interactor.
- myRWInteractor = SVTK_RenderWindowInteractor::New();
- myRWInteractor->SetRenderWindow( myRenderWindow->getRenderWindow() );
- //myRWInteractor->setViewWindow( this );
-
+ myView = new SVTK_View( aSplitter, "TopView" );
+ /*
+ SVTK_View* bottomView = new SVTK_View( aSplitter, "BottomView" );
+ bottomView->getInteractor()->SetInteractorStyle( myInteractorStyle );
+ bottomView->Initialize();
+ */
myInteractorStyle = SVTK_InteractorStyle::New();
- myInteractorStyle->setGUIWindow( myRenderWindow );
+ myInteractorStyle->setGUIWindow( myView );
myInteractorStyle->setViewWindow( this );
- myRWInteractor->SetInteractorStyle( myInteractorStyle );
- myRWInteractor->Initialize();
+ myView->SetInteractorStyle( myInteractorStyle );
+ myView->SetSelector( mySelector );
+ myView->Initialize();
//merge with V2_2_0_VISU_improvements:myInteractorStyle->setTriedron( myTrihedron );
myInteractorStyle->FindPokedRenderer( 0, 0 );
- SetSelectionMode(ActorSelection);
-
- vtkTextProperty* tprop = vtkTextProperty::New();
- tprop->SetColor(1, 1, 1);
- tprop->ShadowOn();
-
- float bnd[6];
- bnd[0] = bnd[2] = bnd[4] = 0;
- bnd[1] = bnd[3] = bnd[5] = myTrihedron->GetSize();
- myCubeAxes->SetLabelFormat("%6.4g");
- myCubeAxes->SetBounds(bnd);
- myCubeAxes->SetCamera(myRenderer->GetActiveCamera());
- myCubeAxes->SetFlyModeToOuterEdges(); // ENK remarks: it must bee
- myCubeAxes->SetFontFactor(0.8);
- myCubeAxes->SetAxisTitleTextProperty(tprop);
- myCubeAxes->SetAxisLabelTextProperty(tprop);
- myCubeAxes->SetCornerOffset(0);
- myCubeAxes->SetScaling(0);
- myCubeAxes->SetNumberOfLabels(5);
- myCubeAxes->VisibilityOff();
- myCubeAxes->SetTransform(myTransform);
- tprop->Delete();
-
- setCentralWidget( myRenderWindow );
-
- myToolBar = new QToolBar(this);
- myToolBar->setCloseMode(QDockWindow::Undocked);
- myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
-
- createActions();
- createToolBar();
+ SetSelectionMode( ActorSelection );
+
+ myView->setFocusPolicy( StrongFocus );
+ myView->setFocus();
+ /*
connect( myRenderWindow, SIGNAL(KeyPressed( QKeyEvent* )),
this, SLOT(onKeyPressed( QKeyEvent* )) );
connect( myRenderWindow, SIGNAL(KeyReleased( QKeyEvent* )),
this, SLOT(onMouseDoubleClicked( QMouseEvent* )) );
connect( myRenderWindow, SIGNAL(MouseMove( QMouseEvent* )),
this, SLOT(onMouseMoving( QMouseEvent* )) );
+ */
connect( myInteractorStyle, SIGNAL(RenderWindowModified()),
- myRenderWindow, SLOT(update()) );
- connect( myRWInteractor, SIGNAL(RenderWindowModified()),
- myRenderWindow, SLOT(update()) );
- connect( myRWInteractor, SIGNAL(contextMenuRequested( QContextMenuEvent * )),
- this, SIGNAL(contextMenuRequested( QContextMenuEvent * )) );
+ myView, SLOT(update()) );
+ connect( myView, SIGNAL(contextMenuRequested( QContextMenuEvent * )),
+ this, SIGNAL(contextMenuRequested( QContextMenuEvent * )) );
onResetView();
}
SVTK_ViewWindow
::~SVTK_ViewWindow()
{
- myTransform->Delete();
// In order to ensure that the interactor unregisters
// this RenderWindow, we assign a NULL RenderWindow to
// it before deleting it.
- myRWInteractor->SetRenderWindow( NULL );
- myRWInteractor->Delete();
-
- //m_RW->Delete() ;
- myRenderer->RemoveAllProps();
- //m_Renderer->Delete();
- myTrihedron->Delete();
- myCubeAxes->Delete();
+ //myView->SetRenderWindow( NULL );
+ //delete myView;
}
//----------------------------------------------------------------------------
-void
+vtkRenderer*
SVTK_ViewWindow
-::activateZoom()
+::getRenderer()
{
- myInteractorStyle->startZoom();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_ViewWindow
-::activatePanning()
-{
- myInteractorStyle->startPan();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_ViewWindow
-::activateRotation()
-{
- myInteractorStyle->startRotate();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_ViewWindow
-::activateGlobalPanning()
-{
- if(myTrihedron->GetVisibleActorCount(myRenderer))
- myInteractorStyle->startGlobalPan();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_ViewWindow
-::activateWindowFit()
-{
- myInteractorStyle->startFitArea();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_ViewWindow
-::createActions()
-{
- if (!myActionsMap.isEmpty()) return;
-
- SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
-
- QtxAction* aAction;
-
- // Dump view
- aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
- tr( "MNU_DUMP_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onDumpView()));
- myActionsMap[ DumpId ] = aAction;
-
- // FitAll
- aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
- tr( "MNU_FITALL" ), 0, this);
- aAction->setStatusTip(tr("DSC_FITALL"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onFitAll()));
- myActionsMap[ FitAllId ] = aAction;
-
- // FitRect
- aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
- tr( "MNU_FITRECT" ), 0, this);
- aAction->setStatusTip(tr("DSC_FITRECT"));
- connect(aAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
- myActionsMap[ FitRectId ] = aAction;
-
- // Zoom
- aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
- tr( "MNU_ZOOM_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(activateZoom()));
- myActionsMap[ ZoomId ] = aAction;
-
- // Panning
- aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
- tr( "MNU_PAN_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_PAN_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(activatePanning()));
- myActionsMap[ PanId ] = aAction;
-
- // Global Panning
- aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
- tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
- myActionsMap[ GlobalPanId ] = aAction;
-
- // Rotation
- aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
- tr( "MNU_ROTATE_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(activateRotation()));
- myActionsMap[ RotationId ] = aAction;
-
- // Projections
- aAction = new QtxAction(tr("MNU_FRONT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
- tr( "MNU_FRONT_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_FRONT_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onFrontView()));
- myActionsMap[ FrontId ] = aAction;
-
- aAction = new QtxAction(tr("MNU_BACK_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
- tr( "MNU_BACK_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_BACK_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onBackView()));
- myActionsMap[ BackId ] = aAction;
-
- aAction = new QtxAction(tr("MNU_TOP_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
- tr( "MNU_TOP_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_TOP_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onTopView()));
- myActionsMap[ TopId ] = aAction;
-
- aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
- tr( "MNU_BOTTOM_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onBottomView()));
- myActionsMap[ BottomId ] = aAction;
-
- aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
- tr( "MNU_LEFT_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_LEFT_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onLeftView()));
- myActionsMap[ LeftId ] = aAction;
-
- aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
- tr( "MNU_RIGHT_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onRightView()));
- myActionsMap[ RightId ] = aAction;
-
- // Reset
- aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
- tr( "MNU_RESET_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_RESET_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onResetView()));
- myActionsMap[ ResetId ] = aAction;
-
- // onViewTrihedron: Shows - Hides Trihedron
- aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
- tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
- aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewTrihedron()));
- myActionsMap[ ViewTrihedronId ] = aAction;
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_ViewWindow
-::createToolBar()
-{
- myActionsMap[DumpId]->addTo(myToolBar);
- myActionsMap[ViewTrihedronId]->addTo(myToolBar);
-
- SUIT_ToolButton* aScaleBtn = new SUIT_ToolButton(myToolBar);
- aScaleBtn->AddAction(myActionsMap[FitAllId]);
- aScaleBtn->AddAction(myActionsMap[FitRectId]);
- aScaleBtn->AddAction(myActionsMap[ZoomId]);
-
- SUIT_ToolButton* aPanningBtn = new SUIT_ToolButton(myToolBar);
- aPanningBtn->AddAction(myActionsMap[PanId]);
- aPanningBtn->AddAction(myActionsMap[GlobalPanId]);
-
- myActionsMap[RotationId]->addTo(myToolBar);
-
- SUIT_ToolButton* aViewsBtn = new SUIT_ToolButton(myToolBar);
- aViewsBtn->AddAction(myActionsMap[FrontId]);
- aViewsBtn->AddAction(myActionsMap[BackId]);
- aViewsBtn->AddAction(myActionsMap[TopId]);
- aViewsBtn->AddAction(myActionsMap[BottomId]);
- aViewsBtn->AddAction(myActionsMap[LeftId]);
- aViewsBtn->AddAction(myActionsMap[RightId]);
-
- myActionsMap[ResetId]->addTo(myToolBar);
+ return myView->getRenderer();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onFrontView()
{
- vtkCamera* camera = myRenderer->GetActiveCamera();
- camera->SetPosition(1,0,0);
- camera->SetViewUp(0,0,1);
- camera->SetFocalPoint(0,0,0);
- onFitAll();
+ myView->onFrontView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onBackView()
{
- vtkCamera* camera = myRenderer->GetActiveCamera();
- camera->SetPosition(-1,0,0);
- camera->SetViewUp(0,0,1);
- camera->SetFocalPoint(0,0,0);
- onFitAll();
+ myView->onBackView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onTopView()
{
- vtkCamera* camera = myRenderer->GetActiveCamera();
- camera->SetPosition(0,0,1);
- camera->SetViewUp(0,1,0);
- camera->SetFocalPoint(0,0,0);
- onFitAll();
+ myView->onTopView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onBottomView()
{
- vtkCamera* camera = myRenderer->GetActiveCamera();
- camera->SetPosition(0,0,-1);
- camera->SetViewUp(0,1,0);
- camera->SetFocalPoint(0,0,0);
- onFitAll();
+ myView->onBottomView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onLeftView()
{
- vtkCamera* camera = myRenderer->GetActiveCamera();
- camera->SetPosition(0,-1,0);
- camera->SetViewUp(0,0,1);
- camera->SetFocalPoint(0,0,0);
- onFitAll();
+ myView->onLeftView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onRightView()
{
- vtkCamera* camera = myRenderer->GetActiveCamera();
- camera->SetPosition(0,1,0);
- camera->SetViewUp(0,0,1);
- camera->SetFocalPoint(0,0,0);
- onFitAll();
+ myView->onRightView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onResetView()
{
- int aTrihedronIsVisible = isTrihedronDisplayed();
- int aCubeAxesIsVisible = isCubeAxesDisplayed();
-
- myTrihedron->SetVisibility( VTKViewer_Trihedron::eOnlyLineOn );
- myCubeAxes->SetVisibility(0);
-
- ::ResetCamera(myRenderer,true);
- vtkCamera* aCamera = myRenderer->GetActiveCamera();
- aCamera->SetPosition(1,-1,1);
- aCamera->SetViewUp(0,0,1);
- ::ResetCamera(myRenderer,true);
-
- if (aTrihedronIsVisible) myTrihedron->VisibilityOn();
- else myTrihedron->VisibilityOff();
-
- if (aCubeAxesIsVisible) myCubeAxes->VisibilityOn();
- else myCubeAxes->VisibilityOff();
-
- static float aCoeff = 3.0;
- aCamera->SetParallelScale(aCoeff*aCamera->GetParallelScale());
- Repaint();
+ myView->onResetView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onFitAll()
{
- int aTrihedronWasVisible = false;
- int aCubeAxesWasVisible = false;
- if (myTrihedron) {
- aTrihedronWasVisible = isTrihedronDisplayed();
- if (aTrihedronWasVisible)
- myTrihedron->VisibilityOff();
- }
-
- if (myCubeAxes) {
- aCubeAxesWasVisible = isCubeAxesDisplayed();
- if (aCubeAxesWasVisible)
- myCubeAxes->VisibilityOff();
- }
-
- if (myTrihedron->GetVisibleActorCount(myRenderer)) {
- myTrihedron->VisibilityOff();
- myCubeAxes->VisibilityOff();
- ::ResetCamera(myRenderer);
- } else {
- myTrihedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn);
- myCubeAxes->SetVisibility(2);
- ::ResetCamera(myRenderer,true);
- }
-
- if (aTrihedronWasVisible)
- myTrihedron->VisibilityOn();
- else
- myTrihedron->VisibilityOff();
-
- if (aCubeAxesWasVisible)
- myCubeAxes->VisibilityOn();
- else
- myCubeAxes->VisibilityOff();
-
- ::ResetCameraClippingRange(myRenderer);
-
- Repaint();
+ myView->onFitAll();
}
-//----------------------------------------------------------------
-struct THighlightAction{
- bool myIsHighlight;
- THighlightAction( bool theIsHighlight ): myIsHighlight(theIsHighlight) {}
- void operator()( SALOME_Actor* theActor) {
- if(theActor->GetMapper()){
- theActor->highlight( myIsHighlight );
- }
- }
-};
-
//----------------------------------------------------------------
void
SVTK_ViewWindow
::onSelectionChanged()
{
- unHighlightAll();
-
- const SALOME_ListIO& aListIO = mySelector->StoredIObjects();
- SALOME_ListIteratorOfListIO anIter(aListIO);
- for(; anIter.More(); anIter.Next()){
- highlight(anIter.Value(),true,!anIter.More());
- }
-
- emit selectionChanged();
+ myView->onSelectionChanged();
}
//----------------------------------------------------------------
SVTK_ViewWindow
::SetSelectionMode(Selection_Mode theMode)
{
- mySelector->SetSelectionMode(theMode);
-
- //myRWInteractor->SetSelectionMode(theMode);
+ myView->SetSelectionMode( theMode );
}
//----------------------------------------------------------------
SVTK_ViewWindow
::SelectionMode() const
{
- return mySelector->SelectionMode();
+ return myView->SelectionMode();
}
//----------------------------------------------------------------
SVTK_ViewWindow
::unHighlightAll()
{
- //cout << "--------------------------------------------------" << endl;
- //cout << "SVTK_ViewWindow::unHighlightAll" << endl;
-
- using namespace VTK;
- ForEach<SALOME_Actor>( myRenderer->GetActors(),
- THighlightAction( false ) );
-
- //myRenderWindow->update();
+ myView->unHighlightAll();
}
//----------------------------------------------------------------
bool theIsHighlight,
bool theIsUpdate )
{
- using namespace VTK;
- ForEachIf<SALOME_Actor>(myRenderer->GetActors(),
- TIsSameIObject<SALOME_Actor>(theIO),
- THighlightAction(theIsHighlight));
-
- //myRenderWindow->update();
+ myView->highlight( theIO, theIsHighlight, theIsUpdate );
}
//----------------------------------------------------------------
SVTK_ViewWindow
::isInViewer( const Handle(SALOME_InteractiveObject)& theIO )
{
- return myRWInteractor->isInViewer( theIO );
+ return myView->isInViewer( theIO );
}
//----------------------------------------------------------------
SVTK_ViewWindow
::isVisible( const Handle(SALOME_InteractiveObject)& theIO )
{
- return myRWInteractor->isVisible( theIO );
+ return myView->isVisible( theIO );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::setBackgroundColor( const QColor& color )
{
- if ( myRenderer )
- myRenderer->SetBackground( color.red()/255., color.green()/255., color.blue()/255. );
+ myView->setBackgroundColor( color );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::backgroundColor() const
{
- float backint[3];
- if ( myRenderer ) {
- myRenderer->GetBackground( backint );
- return QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255));
- }
- return SUIT_ViewWindow::backgroundColor();
+ return myView->backgroundColor();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::Repaint(bool theUpdateTrihedron)
{
- if (theUpdateTrihedron)
- onAdjustTrihedron();
- myRenderWindow->update();
+ myView->Repaint( theUpdateTrihedron );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::GetScale( double theScale[3] )
{
- myTransform->GetMatrixScale( theScale );
+ myView->GetScale( theScale );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::SetScale( double theScale[3] )
{
- myTransform->SetMatrixScale( theScale[0], theScale[1], theScale[2] );
- myRWInteractor->Render();
- Repaint();
+ myView->SetScale( theScale );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::isTrihedronDisplayed()
{
- return myTrihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
+ return myView->isTrihedronDisplayed();
}
bool
SVTK_ViewWindow
::isCubeAxesDisplayed()
{
- return myCubeAxes->GetVisibility() == 1;
+ return myView->isCubeAxesDisplayed();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onViewTrihedron()
{
- if(!myTrihedron)
- return;
-
- if(isTrihedronDisplayed())
- myTrihedron->VisibilityOff();
- else
- myTrihedron->VisibilityOn();
-
- Repaint();
+ myView->onViewTrihedron();
}
void
SVTK_ViewWindow
::onViewCubeAxes()
{
- if(!myCubeAxes)
- return;
-
- if(isCubeAxesDisplayed())
- myCubeAxes->VisibilityOff();
- else
- myCubeAxes->VisibilityOn();
-
- Repaint();
+ myView->onViewCubeAxes();
}
//----------------------------------------------------------------------------
}*/
//----------------------------------------------------------------------------
+VTKViewer_Trihedron* SVTK_ViewWindow::GetTrihedron()
+{
+ return myView->GetTrihedron();
+}
+
+SVTK_CubeAxesActor2D* SVTK_ViewWindow::GetCubeAxes()
+{
+ return myView->GetCubeAxes();
+}
+
int SVTK_ViewWindow::GetTrihedronSize() const
{
- return myTrihedronSize;
+ return myView->GetTrihedronSize();
}
void SVTK_ViewWindow::SetTrihedronSize( const int sz )
{
- if ( myTrihedronSize == sz )
- return;
-
- myTrihedronSize = sz;
- AdjustTrihedrons( true );
+ myView->SetTrihedronSize( sz );
}
/*! If parameter theIsForcedUpdate is true, recalculate parameters for
SVTK_ViewWindow
::AdjustTrihedrons(const bool theIsForcedUpdate)
{
- if ((!isCubeAxesDisplayed() && !isTrihedronDisplayed()) && !theIsForcedUpdate)
- return;
-
- float bnd[ 6 ];
- float newbnd[6];
- newbnd[ 0 ] = newbnd[ 2 ] = newbnd[ 4 ] = VTK_LARGE_FLOAT;
- newbnd[ 1 ] = newbnd[ 3 ] = newbnd[ 5 ] = -VTK_LARGE_FLOAT;
-
- myCubeAxes->GetBounds(bnd);
-
- int aVisibleNum = myTrihedron->GetVisibleActorCount( myRenderer );
- //if (aVisibleNum || theIsForcedUpdate) {
- if (aVisibleNum) {
- // if the new trihedron size have sufficient difference, then apply the value
- double aNewSize = 100, anOldSize=myTrihedron->GetSize();
- bool aTDisplayed = isTrihedronDisplayed();
- bool aCDisplayed = isCubeAxesDisplayed();
- if(aTDisplayed) myTrihedron->VisibilityOff();
- if(aCDisplayed) myCubeAxes->VisibilityOff();
-
- SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
- QString aSetting = aResMgr->stringValue("Viewer:TrihedronSize", "105");
- static float aSizeInPercents = aSetting.toFloat();
-
- //bool isComputeTrihedronSize =
- ::ComputeTrihedronSize(myRenderer, aNewSize, anOldSize, aSizeInPercents);
-
- myTrihedron->SetSize( aNewSize );
-
- // iterate through displayed objects and set size if necessary
- vtkActorCollection* anActors = getRenderer()->GetActors();
- anActors->InitTraversal();
- while (vtkActor* anActor = anActors->GetNextActor())
- {
- if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast( anActor ))
- {
- if (aSActor->IsResizable())
- aSActor->SetSize( 0.5 * aNewSize );
- if (aSActor->GetVisibility() && !aSActor->IsInfinitive()) {
- float *abounds = aSActor->GetBounds();
- if (abounds[0] > -VTK_LARGE_FLOAT && abounds[1] < VTK_LARGE_FLOAT &&
- abounds[2] > -VTK_LARGE_FLOAT && abounds[3] < VTK_LARGE_FLOAT &&
- abounds[4] > -VTK_LARGE_FLOAT && abounds[5] < VTK_LARGE_FLOAT)
- for (int i = 0; i < 5; i = i + 2) {
- if (abounds[i] < newbnd[i]) newbnd[i] = abounds[i];
- if (abounds[i+1] > newbnd[i+1]) newbnd[i+1] = abounds[i+1];
- }
- }
- }
- }
- if (aTDisplayed) myTrihedron->VisibilityOn();
- if (aCDisplayed) myCubeAxes->VisibilityOn();
-
- } else {
- double aSize = myTrihedron->GetSize();
- newbnd[0] = newbnd[2] = newbnd[4] = 0;
- newbnd[1] = newbnd[3] = newbnd[5] = aSize;
- }
-
- if (newbnd[0] < VTK_LARGE_FLOAT && newbnd[2] < VTK_LARGE_FLOAT && newbnd[4] < VTK_LARGE_FLOAT &&
- newbnd[1] >-VTK_LARGE_FLOAT && newbnd[3] >-VTK_LARGE_FLOAT && newbnd[5] >-VTK_LARGE_FLOAT) {
- for(int i=0;i<6;i++) bnd[i] = newbnd[i];
- myCubeAxes->SetBounds(bnd);
- }
-
- myCubeAxes->SetBounds(bnd);
-
- ::ResetCameraClippingRange(myRenderer);
+ myView->AdjustTrihedrons( theIsForcedUpdate );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onAdjustTrihedron()
{
- AdjustTrihedrons( false );
+ myView->onAdjustTrihedron();
}
void
SVTK_ViewWindow
::onAdjustCubeAxes()
{
- AdjustTrihedrons(false);
+ myView->onAdjustCubeAxes();
}
#define INCREMENT_FOR_OP 10
SVTK_ViewWindow
::InsertActor( VTKViewer_Actor* theActor, bool theMoveInternalActors )
{
- //cout << "SVTK_ViewWindow::InsertActor" << endl;
- theActor->AddToRender(myRenderer);
-
- theActor->SetTransform(myTransform);
- //if(theMoveInternalActors)
- // myRWInteractor->MoveInternalActors();
+ myView->InsertActor( theActor, theMoveInternalActors );
}
//----------------------------------------------------------------------------
void
SVTK_ViewWindow
-::AddActor( VTKViewer_Actor* theActor, bool theUpdate /*=false*/ )
+::AddActor( VTKViewer_Actor* theActor, bool theUpdate )
{
- InsertActor(theActor);
- if(theUpdate)
- Repaint();
+ myView->AddActor( theActor, theUpdate );
}
//----------------------------------------------------------------------------
void
SVTK_ViewWindow
-::RemoveActor( VTKViewer_Actor* theActor, bool theUpdate /*=false*/ )
+::RemoveActor( VTKViewer_Actor* theActor, bool theUpdate )
{
- //cout << "SVTK_ViewWindow::RemoveActor" << endl;
- theActor->RemoveFromRender(myRenderer);
-
- theActor->RemoveFromRender(myRenderer);
- if(theUpdate)
- Repaint();
+ myView->RemoveActor( theActor, theUpdate );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::MoveActor( VTKViewer_Actor* theActor)
{
- RemoveActor(theActor);
- InsertActor(theActor,true);
+ myView->MoveActor( theActor );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::dumpView()
{
- QPixmap px = QPixmap::grabWindow( myRenderWindow->winId() );
+ QPixmap px = QPixmap::grabWindow( myView->winId() );
return px.convertToImage();
}
+//----------------------------------------------------------------------------
void
SVTK_ViewWindow
::SetSelectionProp(const double& theRed,
const double& theBlue,
const int& theWidth)
{
- vtkActorCollection* anActors = getRenderer()->GetActors();
+ vtkActorCollection* anActors = myView->getRenderer()->GetActors();
anActors->InitTraversal();
while( vtkActor* anActor = anActors->GetNextActor() )
{
}
}
+//----------------------------------------------------------------------------
void
SVTK_ViewWindow
::SetSelectionTolerance(const double& theTolNodes,
const double& theTolItems)
{
- vtkActorCollection* anActors = getRenderer()->GetActors();
+ vtkActorCollection* anActors = myView->getRenderer()->GetActors();
anActors->InitTraversal();
while( vtkActor* anActor = anActors->GetNextActor() )
{
#endif
#include "SVTK.h"
+#include "SVTK_View.h"
+#include "SVTK_Selection.h"
+
#include "SUIT_ViewWindow.h"
-#include "SVTK_Selection.h"
#include "SALOME_InteractiveObject.hxx"
-class vtkRenderer;
-
-class QtxAction;
class SUIT_Desktop;
-class VTKViewer_Trihedron;
-class VTKViewer_Transform;
-
class VTKViewer_Actor;
+class VTKViewer_Trihedron;
class SVTK_Viewer;
class SVTK_Selector;
-class SVTK_CubeAxesActor2D;
-class SVTK_RenderWindow;
-class SVTK_InteractorStyle;
-class SVTK_RenderWindowInteractor;
+//class SVTK_View;
+//class SVTK_RenderWindowInteractor;
class SVTK_InteractorStyle;
+class SVTK_CubeAxesActor2D;
+
+class vtkRenderer;
class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
{
- Q_OBJECT;
+ Q_OBJECT
public:
SVTK_ViewWindow( SUIT_Desktop*, SVTK_Viewer* );
virtual ~SVTK_ViewWindow();
- QToolBar* getToolBar() { return myToolBar; }
-
void setBackgroundColor( const QColor& );
QColor backgroundColor() const;
- vtkRenderer* getRenderer() {return myRenderer;}
+ vtkRenderer* getRenderer();
SVTK_Selector* GetSelector() {return mySelector;}
- SVTK_RenderWindow* getRenderWindow() {return myRenderWindow;}
- SVTK_RenderWindowInteractor* getRWInteractor() {return myRWInteractor;}
+
+ SVTK_View* getView() { return myView; }
+ SVTK_View* getRenderWindow() { return myView; }
+ SVTK_View* getRWInteractor() { return myView; }
SVTK_InteractorStyle* getInteractorStyle(){ return myInteractorStyle;}
+
Selection_Mode SelectionMode() const;
void SetSelectionMode(Selection_Mode theMode);
//merge with V2_2_0_VISU_improvements:bool ComputeTrihedronSize( double& theNewSize,
//merge with V2_2_0_VISU_improvements: double& theOldSize );
+ VTKViewer_Trihedron* GetTrihedron();
+ SVTK_CubeAxesActor2D* GetCubeAxes();
+
int GetTrihedronSize() const;
void SetTrihedronSize( const int );
- VTKViewer_Trihedron* GetTrihedron() {return this->myTrihedron;};
- SVTK_CubeAxesActor2D* GetCubeAxes() {return this->myCubeAxes;};
-
void SetSelectionProp(const double& theRed = 1,
const double& theGreen = 1,
const double& theBlue = 0,
void onBottomView();
void onRightView();
void onLeftView();
-
void onResetView();
void onFitAll();
void onRotateUp();
void onRotateDown();
- void activateZoom();
- void activateWindowFit();
- void activateRotation();
- void activatePanning();
- void activateGlobalPanning();
-
protected:
QImage dumpView();
void MoveActor( VTKViewer_Actor* theActor );
private:
- enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
- FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, ViewTrihedronId };
- typedef QMap<int, QtxAction*> ActionsMap;
-
- void createActions();
- void createToolBar();
-
- vtkRenderer* myRenderer;
-
SVTK_Viewer* myModel;
SVTK_Selector* mySelector;
- SVTK_RenderWindow* myRenderWindow;
- SVTK_RenderWindowInteractor* myRWInteractor;
+ SVTK_View* myView;
SVTK_InteractorStyle* myInteractorStyle;
- VTKViewer_Transform* myTransform;
- VTKViewer_Trihedron* myTrihedron;
- int myTrihedronSize;
- SVTK_CubeAxesActor2D* myCubeAxes;
-
- QToolBar* myToolBar;
- ActionsMap myActionsMap;
-
double myCurScale;
friend class SVTK_RenderWindowInteractor;