-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include "SVTK_NonIsometricDlg.h"
#include "SVTK_UpdateRateDlg.h"
#include "SVTK_CubeAxesDlg.h"
+#include "SVTK_PsOptionsDlg.h"
#include "SVTK_SetRotationPointDlg.h"
#include "SVTK_ViewParameterDlg.h"
#include "SVTK_ViewModel.h"
#include "VTKViewer_Utilities.h"
#include "VTKViewer_Trihedron.h"
+#include "VTKViewer_Actor.h"
#include "SVTK_View.h"
#include "SVTK_Selector.h"
#include <OpenGLUtils_FrameBuffer.h>
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
namespace SVTK
{
*/
void SVTK_ViewWindow::SetProjectionMode(const int theMode)
{
- SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
+ QtxAction* aParallelAction = dynamic_cast<QtxAction*>( toolMgr()->action( ParallelModeId ) );
+ QtxAction* aProjectionAction = dynamic_cast<QtxAction*>( toolMgr()->action( ProjectionModeId ) );
+ QtxAction* aStereoAction = dynamic_cast<QtxAction*>( toolMgr()->action( StereoModeId ) );
- if ( theMode != Stereo ) {
- aViewer->setProjectionMode(theMode);
- bool anIsParallelMode = (theMode == Parallel);
- vtkCamera* aCamera = getRenderer()->GetActiveCamera();
- aCamera->SetParallelProjection(anIsParallelMode);
- GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
- getRenderWindow()->SetStereoRender(0);
- }
- else {
- SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
- SetStereoType( aResMgr->integerValue( "VTKViewer", "stereo_type", 0 ) );
- getRenderWindow()->SetStereoRender(1);
+ switch ( theMode ) {
+ case Parallel:
+ onProjectionMode( aParallelAction );
+ break;
+ case Projection:
+ onProjectionMode( aProjectionAction );
+ break;
+ case Stereo:
+ onStereoMode( true );
+ break;
}
- Repaint();
// update action state if method is called outside
- QtxAction* aParallelAction = dynamic_cast<QtxAction*>( toolMgr()->action( ParallelModeId ) );
- QtxAction* aProjectionAction = dynamic_cast<QtxAction*>( toolMgr()->action( ProjectionModeId ) );
- QtxAction* aStereoAction = dynamic_cast<QtxAction*>( toolMgr()->action( StereoModeId ) );
+ SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
QtxAction* aSwitchZoomingStyle = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchZoomingStyleId ) );
if ( theMode == Parallel && !aParallelAction->isChecked() ) {
aParallelAction->setChecked( true );
aProjectionAction->setEnabled( false );
aProjectionAction->setChecked( true );
if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() &&
- strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 ){
+ strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 &&
+ toolMgr()->action( StereoModeId )->isChecked() ) {
SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ), tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
}
}
aProjectionAction->setEnabled( true );
aStereoAction->setChecked( false );
aProjectionAction->setChecked( aViewer->projectionMode() == Projection );
- onPerspectiveMode();
+ onProjectionMode();
}
}
else {
}
}
+/*!
+ Set support quad-buffered stereo
+ \param theEnable - enable/disable support quad-buffered stereo
+*/
+void SVTK_ViewWindow::SetQuadBufferSupport(const bool theEnable)
+{
+ vtkRenderWindow* aWindow = getRenderWindow();
+ aWindow->SetStereoCapableWindow((int)theEnable);
+}
+
/*!
\return OpenGl stereo support
*/
dynamic_cast<QtxActionGroup*>( getAction( PreselectionId ) );
if ( aPreselectionGroup )
aPreselectionGroup->setEnabled( theEnable );
+
+ // notify actors
+ vtkActorCollection *actors = getRenderer()->GetActors();
+ for (int i = 0; i < actors->GetNumberOfItems(); ++i )
+ if (VTKViewer_Actor *actor = dynamic_cast<VTKViewer_Actor*>(actors->GetItemAsObject(i)))
+ {
+ cout << "actor " << actor << endl;
+ actor->EnableSelection( theEnable );
+ }
}
/*!
if ( format != "PS" && format != "EPS" && format != "PDF" )
return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
- SUIT_OverrideCursor wc;
-
- vtkGL2PSExporter *anExporter = vtkGL2PSExporter::New();
- anExporter->SetRenderWindow(getRenderWindow());
+ SVTK_PsOptionsDlg* optionsDlg = new SVTK_PsOptionsDlg(this);
+ if ( optionsDlg->exec() == QDialog::Accepted ) {
+ SUIT_OverrideCursor wc;
- if ( format == "PS" ) {
- anExporter->SetFileFormatToPS();
- anExporter->CompressOff();
- }
+ vtkGL2PSExporter *anExporter = vtkGL2PSExporter::New();
+ anExporter->SetRenderWindow(getRenderWindow());
- if ( format == "EPS" ) {
- anExporter->SetFileFormatToEPS();
- anExporter->CompressOff();
- }
+ // Set options
+ anExporter->SetLineWidthFactor(optionsDlg->getLineFactor());
+ anExporter->SetPointSizeFactor(optionsDlg->getPointFactor());
+ anExporter->SetSort((vtkGL2PSExporter::SortScheme)optionsDlg->getSortType());
+ anExporter->SetWrite3DPropsAsRasterImage((int)optionsDlg->isRasterize3D());
+ anExporter->SetPS3Shading((int)optionsDlg->isPs3Shading());
+
+ if ( format == "PS" ) {
+ anExporter->SetFileFormatToPS();
+ anExporter->CompressOff();
+ }
+
+ if ( format == "EPS" ) {
+ anExporter->SetFileFormatToEPS();
+ anExporter->CompressOff();
+ }
- if ( format == "PDF" ) {
- anExporter->SetFileFormatToPDF();
+ if ( format == "PDF" ) {
+ anExporter->SetFileFormatToPDF();
+ }
+
+ QString aFilePrefix(fileName);
+ QString anExtension(SUIT_Tools::extension(fileName));
+ aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length());
+ anExporter->SetFilePrefix(aFilePrefix.toLatin1().data());
+ anExporter->Write();
+ anExporter->Delete();
}
-
- QString aFilePrefix(fileName);
- QString anExtension(SUIT_Tools::extension(fileName));
- aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length());
- anExporter->SetFilePrefix(aFilePrefix.toLatin1().data());
- anExporter->Write();
- anExporter->Delete();
-
- return true;
+ delete optionsDlg;
+ return true;
}
/*!
myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0);
}
+/*!
+ \brief Set the given projection mode.
+
+ Set the given projection mode: Orthographic or Perspective.
+*/
+void SVTK_ViewWindow::onProjectionMode( QAction* theAction )
+{
+ int aMode = Parallel;
+ if (theAction == toolMgr()->action( ProjectionModeId ))
+ aMode = Projection;
+ SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
+ aViewer->setProjectionMode(aMode);
+ bool anIsParallelMode = (aMode == Parallel);
+ vtkCamera* aCamera = getRenderer()->GetActiveCamera();
+ aCamera->SetParallelProjection(anIsParallelMode);
+ GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
+ getRenderWindow()->SetStereoRender(0);
+ Repaint();
+}
+
+/*!
+ \brief Sets Stereo projection mode.
+
+ Sets Stereo projection mode.
+*/
+void SVTK_ViewWindow::onStereoMode( bool activate )
+{
+ if (activate) {
+ toolMgr()->action( ProjectionModeId )->setChecked(true);
+ vtkCamera* aCamera = getRenderer()->GetActiveCamera();
+ aCamera->SetParallelProjection(false);
+ toolMgr()->action( ProjectionModeId )->actionGroup()->setEnabled(false);
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ SetStereoType( aResMgr->integerValue( "VTKViewer", "stereo_type", 0 ) );
+ getRenderWindow()->SetStereoRender(1);
+ Repaint();
+ }
+ else {
+ toolMgr()->action( ProjectionModeId )->actionGroup()->setEnabled(true);
+ SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
+ if (aViewer->projectionMode() == Parallel) {
+ toolMgr()->action( ParallelModeId )->setChecked(true);
+ onProjectionMode(toolMgr()->action( ParallelModeId ));
+ }
+ else if (aViewer->projectionMode() == Projection) {
+ toolMgr()->action( ProjectionModeId )->setChecked(true);
+ onProjectionMode(toolMgr()->action( ProjectionModeId ));
+ }
+ }
+ if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() &&
+ strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 &&
+ toolMgr()->action( StereoModeId )->isChecked() )
+ SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ), tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
+}
+
/*!
Set the view projection mode: orthogonal or perspective
*/
-void SVTK_ViewWindow::onPerspectiveMode()
+void SVTK_ViewWindow::onProjectionMode()
{
if (toolMgr()->action( ParallelModeId )->isChecked())
SetProjectionMode( Parallel);
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
tr( "MNU_DUMP_VIEW" ), 0, this);
anAction->setStatusTip(tr("DSC_DUMP_VIEW"));
- connect(anAction, SIGNAL(activated()), this, SLOT(onDumpView()));
+ connect(anAction, SIGNAL(triggered()), this, SLOT(onDumpView()));
mgr->registerAction( anAction, DumpId );
// FitAll
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
tr( "MNU_FITALL" ), 0, this);
anAction->setStatusTip(tr("DSC_FITALL"));
- connect(anAction, SIGNAL(activated()), this, SLOT(onFitAll()));
+ connect(anAction, SIGNAL(triggered()), this, SLOT(onFitAll()));
mgr->registerAction( anAction, FitAllId );
// FitRect
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
tr( "MNU_FITRECT" ), 0, this);
anAction->setStatusTip(tr("DSC_FITRECT"));
- connect(anAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
+ connect(anAction, SIGNAL(triggered()), this, SLOT(activateWindowFit()));
mgr->registerAction( anAction, FitRectId );
// FitSelection
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITSELECTION" ) ),
tr( "MNU_FITSELECTION" ), 0, this);
anAction->setStatusTip(tr("DSC_FITSELECTION"));
- connect(anAction, SIGNAL(activated()), this, SLOT(onFitSelection()));
+ connect(anAction, SIGNAL(triggered()), this, SLOT(onFitSelection()));
mgr->registerAction( anAction, FitSelectionId );
// Zoom
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
tr( "MNU_ZOOM_VIEW" ), 0, this);
anAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
- connect(anAction, SIGNAL(activated()), this, SLOT(activateZoom()));
+ connect(anAction, SIGNAL(triggered()), this, SLOT(activateZoom()));
mgr->registerAction( anAction, ZoomId );
// Panning
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
tr( "MNU_PAN_VIEW" ), 0, this);
anAction->setStatusTip(tr("DSC_PAN_VIEW"));
- connect(anAction, SIGNAL(activated()), this, SLOT(activatePanning()));
+ connect(anAction, SIGNAL(triggered()), this, SLOT(activatePanning()));
mgr->registerAction( anAction, PanId );
// Global Panning
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
- connect(anAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
+ connect(anAction, SIGNAL(triggered()), this, SLOT(activateGlobalPanning()));
mgr->registerAction( anAction, GlobalPanId );
// Change rotation point
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
tr( "MNU_ROTATE_VIEW" ), 0, this);
anAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
- connect(anAction, SIGNAL(activated()), this, SLOT(activateRotation()));
+ connect(anAction, SIGNAL(triggered()), this, SLOT(activateRotation()));
mgr->registerAction( anAction, RotationId );
// Projections
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
tr( "MNU_FRONT_VIEW" ), 0, this, false, "Viewers:Front view");
anAction->setStatusTip(tr("DSC_FRONT_VIEW"));
- connect(anAction, SIGNAL(activated()), this, SLOT(onFrontView()));
+ connect(anAction, SIGNAL(triggered()), this, SLOT(onFrontView()));
this->addAction(anAction);
mgr->registerAction( anAction, FrontId );
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
tr( "MNU_BACK_VIEW" ), 0, this, false, "Viewers:Back view");
anAction->setStatusTip(tr("DSC_BACK_VIEW"));
- connect(anAction, SIGNAL(activated()), this, SLOT(onBackView()));
+ connect(anAction, SIGNAL(triggered()), this, SLOT(onBackView()));
this->addAction(anAction);
mgr->registerAction( anAction, BackId );
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
tr( "MNU_TOP_VIEW" ), 0, this, false, "Viewers:Top view");
anAction->setStatusTip(tr("DSC_TOP_VIEW"));
- connect(anAction, SIGNAL(activated()), this, SLOT(onTopView()));
+ connect(anAction, SIGNAL(triggered()), this, SLOT(onTopView()));
this->addAction(anAction);
mgr->registerAction( anAction, TopId );
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
tr( "MNU_BOTTOM_VIEW" ), 0, this, false, "Viewers:Bottom view");
anAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
- connect(anAction, SIGNAL(activated()), this, SLOT(onBottomView()));
+ connect(anAction, SIGNAL(triggered()), this, SLOT(onBottomView()));
this->addAction(anAction);
mgr->registerAction( anAction, BottomId );
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view");
anAction->setStatusTip(tr("DSC_LEFT_VIEW"));
- connect(anAction, SIGNAL(activated()), this, SLOT(onLeftView()));
+ connect(anAction, SIGNAL(triggered()), this, SLOT(onLeftView()));
this->addAction(anAction);
mgr->registerAction( anAction, LeftId );
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
tr( "MNU_RIGHT_VIEW" ), 0, this, false, "Viewers:Right view");
anAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
- connect(anAction, SIGNAL(activated()), this, SLOT(onRightView()));
+ connect(anAction, SIGNAL(triggered()), this, SLOT(onRightView()));
this->addAction(anAction);
mgr->registerAction( anAction, RightId );
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
tr( "MNU_RESET_VIEW" ), 0, this, false, "Viewers:Reset view");
anAction->setStatusTip(tr("DSC_RESET_VIEW"));
- connect(anAction, SIGNAL(activated()), this, SLOT(onResetView()));
+ connect(anAction, SIGNAL(triggered()), this, SLOT(onResetView()));
this->addAction(anAction);
mgr->registerAction( anAction, ResetId );
tr( "MNU_SVTK_PARALLEL_MODE" ), 0, this);
anAction->setStatusTip(tr("DSC_SVTK_PARALLEL_MODE"));
anAction->setCheckable(true);
- //connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode()));
mgr->registerAction( anAction, ParallelModeId );
anAction = new QtxAction(tr("MNU_SVTK_PERSPECTIVE_MODE"),
tr( "MNU_SVTK_PERSPECTIVE_MODE" ), 0, this);
anAction->setStatusTip(tr("DSC_SVTK_PERSPECTIVE_MODE"));
anAction->setCheckable(true);
- //connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode()));
mgr->registerAction( anAction, ProjectionModeId );
anAction = new QtxAction(tr("MNU_SVTK_STEREO_MODE"),
tr( "MNU_SVTK_STEREO_MODE" ), 0, this);
anAction->setStatusTip(tr("DSC_SVTK_STEREO_MODE"));
anAction->setCheckable(true);
- //connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode()));
+ connect(anAction, SIGNAL(triggered(bool)), this, SLOT(onStereoMode(bool)));
mgr->registerAction( anAction, StereoModeId );
QActionGroup* aPerspectiveGroup = new QActionGroup( this );
aPerspectiveGroup->addAction( mgr->action( ParallelModeId ) );
aPerspectiveGroup->addAction( mgr->action( ProjectionModeId ) );
- aPerspectiveGroup->addAction( mgr->action( StereoModeId ) );
- connect(aPerspectiveGroup, SIGNAL(triggered(QAction*)), this, SLOT(onPerspectiveMode()));
+ connect(aPerspectiveGroup, SIGNAL(triggered(QAction*)), this, SLOT(onProjectionMode(QAction*)));
// View Parameters
anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"),
tr( "MNU_SVTK_PRESELECTION_STANDARD" ), 0, this);
anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_STANDARD"));
anAction->setCheckable(true);
- connect(anAction, SIGNAL(activated()), aSignalMapper, SLOT(map()));
+ connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
aSignalMapper->setMapping( anAction, Standard_Preselection );
mgr->registerAction( anAction, StandardPreselectionId );
tr( "MNU_SVTK_PRESELECTION_DYNAMIC" ), 0, this);
anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_DYNAMIC"));
anAction->setCheckable(true);
- connect(anAction, SIGNAL(activated()), aSignalMapper, SLOT(map()));
+ connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
aSignalMapper->setMapping( anAction, Dynamic_Preselection );
mgr->registerAction( anAction, DynamicPreselectionId );
tr( "MNU_SVTK_PRESELECTION_DISABLED" ), 0, this);
anAction->setStatusTip(tr("DSC_SVTK_PRESELECTION_DISABLED"));
anAction->setCheckable(true);
- connect(anAction, SIGNAL(activated()), aSignalMapper, SLOT(map()));
+ connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map()));
aSignalMapper->setMapping( anAction, Preselection_Disabled );
mgr->registerAction( anAction, DisablePreselectionId );