#include <vtkRenderer.h>
#include <vtkCamera.h>
-//****************************************************************
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
+/*! Construction*/
VTKViewer_ViewWindow::VTKViewer_ViewWindow( SUIT_Desktop* theDesktop,
VTKViewer_Viewer* theModel,
VTKViewer_InteractorStyle* iStyle,
VTKViewer_RenderWindowInteractor* rw )
-: SUIT_ViewWindow(theDesktop)
+: SUIT_ViewWindow( theDesktop )
{
myModel = theModel;
onResetView();
}
-//****************************************************************
+/*!Destructor.*/
VTKViewer_ViewWindow::~VTKViewer_ViewWindow()
{
myTransform->Delete();
myTrihedron->Delete();
}
-//****************************************************************
bool VTKViewer_ViewWindow::isTrihedronDisplayed(){
return myTrihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
}
-//****************************************************************
/*!
Activates 'zooming' transformation
*/
myRWInteractor->GetInteractorStyle()->startZoom();
}
-//****************************************************************
/*!
Activates 'panning' transformation
*/
myRWInteractor->GetInteractorStyle()->startPan();
}
-//****************************************************************
/*!
Activates 'rotation' transformation
*/
myRWInteractor->GetInteractorStyle()->startRotate();
}
-//****************************************************************
void VTKViewer_ViewWindow::activateGlobalPanning()
{
//if(myTrihedron->GetVisibleActorCount(myRenderer))
myRWInteractor->GetInteractorStyle()->startGlobalPan();
}
-//****************************************************************
/*!
Activates 'fit area' transformation
*/
myRWInteractor->GetInteractorStyle()->startFitArea();
}
-//****************************************************************
void VTKViewer_ViewWindow::createActions()
{
if (!myActionsMap.isEmpty()) return;
aAction->setStatusTip(tr("DSC_RESET_VIEW"));
connect(aAction, SIGNAL(activated()), this, SLOT(onResetView()));
myActionsMap[ ResetId ] = aAction;
+
+ 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(onTrihedronShow()));
+ myActionsMap[ TrihedronShowId ] = aAction;
}
-//****************************************************************
void VTKViewer_ViewWindow::createToolBar()
{
myActionsMap[DumpId]->addTo(myToolBar);
+ myActionsMap[TrihedronShowId]->addTo(myToolBar);
SUIT_ToolButton* aScaleBtn = new SUIT_ToolButton(myToolBar);
aScaleBtn->AddAction(myActionsMap[FitAllId]);
myActionsMap[ResetId]->addTo(myToolBar);
}
-//****************************************************************
void VTKViewer_ViewWindow::onFrontView()
{
vtkCamera* camera = myRenderer->GetActiveCamera();
onFitAll();
}
-//****************************************************************
void VTKViewer_ViewWindow::onBackView()
{
vtkCamera* camera = myRenderer->GetActiveCamera();
onFitAll();
}
-//****************************************************************
void VTKViewer_ViewWindow::onTopView()
{
vtkCamera* camera = myRenderer->GetActiveCamera();
onFitAll();
}
-//****************************************************************
void VTKViewer_ViewWindow::onBottomView()
{
vtkCamera* camera = myRenderer->GetActiveCamera();
onFitAll();
}
-//****************************************************************
void VTKViewer_ViewWindow::onLeftView()
{
vtkCamera* camera = myRenderer->GetActiveCamera();
onFitAll();
}
-//****************************************************************
void VTKViewer_ViewWindow::onRightView()
{
vtkCamera* camera = myRenderer->GetActiveCamera();
onFitAll();
}
-//****************************************************************
void VTKViewer_ViewWindow::onResetView()
{
int aTriedronIsVisible = isTrihedronDisplayed();
Repaint();
}
-//****************************************************************
void VTKViewer_ViewWindow::onFitAll()
{
myRWInteractor->GetInteractorStyle()->ViewFitAll();
Repaint();
}
-//****************************************************************
-/*
- Dumps 3d-Viewer contents into image file
- File format is defined by file's extension; supported formats : PNG, BMP, GIF, JPG
-*/
-void VTKViewer_ViewWindow::onDumpView()
-{
- QApplication::setOverrideCursor( Qt::waitCursor );
- QPixmap px = QPixmap::grabWindow(myRenderWindow->winId());
- QApplication::restoreOverrideCursor();
-
- SUIT_Application* app = getViewManager()->study()->application();
-
- QString aFileName = app->getFileName( false, QString::null, tr("VTK_IMAGE_FILES"), tr("INF_APP_DUMP_VIEW"), 0 );
-
- if ( !aFileName.isNull() ) {
- QApplication::setOverrideCursor( Qt::waitCursor );
- QString fmt = SUIT_Tools::extension( aFileName ).upper();
- if (fmt.isEmpty())
- fmt = QString("BMP"); // default format
- if (fmt == "JPG")
- fmt = "JPEG";
- bool bOk = px.save(aFileName, fmt.latin1());
- QApplication::restoreOverrideCursor();
- if (!bOk) {
- SUIT_MessageBox::error1(this, tr("ERROR"), tr("ERR_DOC_CANT_SAVE_FILE"), tr("BUT_OK"));
- }
- }
-}
-
-//****************************************************************
/*!
Set background of the viewport
*/
myRenderer->SetBackground( color.red()/255., color.green()/255., color.blue()/255. );
}
-//****************************************************************
/*!
Returns background of the viewport
*/
return SUIT_ViewWindow::backgroundColor();
}
-//****************************************************************
void VTKViewer_ViewWindow::Repaint(bool theUpdateTrihedron)
{
if (theUpdateTrihedron) onAdjustTrihedron();
myRenderWindow->update();
}
-//****************************************************************
void VTKViewer_ViewWindow::GetScale( double theScale[3] ) {
myTransform->GetScale( theScale );
}
-//****************************************************************
void VTKViewer_ViewWindow::SetScale( double theScale[3] ) {
- myTransform->SetScale( theScale[0], theScale[1], theScale[2] );
+ myTransform->SetMatrixScale( theScale[0], theScale[1], theScale[2] );
myRWInteractor->Render();
Repaint();
}
-//****************************************************************
void VTKViewer_ViewWindow::onAdjustTrihedron(){
if( !isTrihedronDisplayed() )
return;
::ResetCameraClippingRange(myRenderer);
}
-//****************************************************************
void VTKViewer_ViewWindow::onKeyPressed(QKeyEvent* event)
{
emit keyPressed( this, event );
}
-//****************************************************************
void VTKViewer_ViewWindow::onKeyReleased(QKeyEvent* event)
{
emit keyReleased( this, event );
}
-//****************************************************************
void VTKViewer_ViewWindow::onMousePressed(QMouseEvent* event)
{
emit mousePressed(this, event);
}
-//****************************************************************
void VTKViewer_ViewWindow::onMouseReleased(QMouseEvent* event)
{
emit mouseReleased( this, event );
}
-//****************************************************************
void VTKViewer_ViewWindow::onMouseMoving(QMouseEvent* event)
{
emit mouseMoving( this, event );
}
-//****************************************************************
void VTKViewer_ViewWindow::onMouseDoubleClicked( QMouseEvent* event )
{
emit mouseDoubleClicked( this, event );
RemoveActor(theActor);
InsertActor(theActor,true);
}
+
+void VTKViewer_ViewWindow::onTrihedronShow()
+{
+ if (isTrihedronDisplayed())
+ myTrihedron->VisibilityOff();
+ else
+ myTrihedron->VisibilityOn();
+ myRenderWindow->update();
+}
+
+QImage VTKViewer_ViewWindow::dumpView()
+{
+ QPixmap px = QPixmap::grabWindow( myRenderWindow->winId() );
+ return px.convertToImage();
+}