Salome HOME
Fixing a bug : Salome GUI style needs addLibraryPath() method to be called
[modules/gui.git] / src / SVTK / SVTK_ViewWindow.cxx
index 3b03d944ecad162dea6b3d9841accc7158e51793..cd140f5fa99436e555f1fafb216eae516eb52eac 100755 (executable)
@@ -1,4 +1,3 @@
-#include "SVTK_Selector.h"
 #include "SALOME_Actor.h"
 
 #include <qapplication.h>
@@ -16,7 +15,6 @@
 
 #include "SUIT_Tools.h"
 #include "SUIT_ResourceMgr.h"
-#include "SUIT_FileDlg.h"
 
 #include "VTKViewer_Transform.h"
 #include "VTKViewer_Utilities.h"
@@ -30,6 +28,8 @@
 
 #include "SALOME_ListIteratorOfListIO.hxx"
 
+#include "SVTK_SelectorDef.h"
+
 #include "VTKViewer_Algorithm.h"
 #include "SVTK_Functor.h"
 
@@ -40,7 +40,7 @@ SVTK_ViewWindow
   : SUIT_ViewWindow(theDesktop)
 {
   myModel = theModel;
-  mySelector = new SVTK_Selector();
+  mySelector = new SVTK_SelectorDef();
   connect(this,SIGNAL(selectionChanged()),theModel,SLOT(onSelectionChanged()));
 
   myTransform = VTKViewer_Transform::New();
@@ -78,9 +78,10 @@ SVTK_ViewWindow
   SVTK_InteractorStyle* RWS = SVTK_InteractorStyle::New();
   RWS->setGUIWindow( myRenderWindow );
   RWS->setViewWindow( this );
-  myRWInteractor->SetInteractorStyle( RWS ); 
 
+  myRWInteractor->SetInteractorStyle( RWS ); 
   myRWInteractor->Initialize();
+
   RWS->setTriedron( myTrihedron );
   RWS->FindPokedRenderer( 0, 0 );
 
@@ -277,6 +278,13 @@ SVTK_ViewWindow
   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;
 }
 
 //----------------------------------------------------------------------------
@@ -285,6 +293,7 @@ SVTK_ViewWindow
 ::createToolBar()
 {
   myActionsMap[DumpId]->addTo(myToolBar);
+  myActionsMap[ViewTrihedronId]->addTo(myToolBar);
 
   SUIT_ToolButton* aScaleBtn = new SUIT_ToolButton(myToolBar);
   aScaleBtn->AddAction(myActionsMap[FitAllId]);
@@ -408,35 +417,6 @@ SVTK_ViewWindow
   Repaint();
 }
 
-//----------------------------------------------------------------------------
-void
-SVTK_ViewWindow
-::onDumpView()
-{
-  QApplication::setOverrideCursor( Qt::waitCursor );
-  QPixmap px = QPixmap::grabWindow(myRenderWindow->winId());
-  QApplication::restoreOverrideCursor();
-  
-  QString fileName = SUIT_FileDlg::getFileName(this,
-                                              QString::null,
-                                              tr("VTK_IMAGE_FILES"),
-                                              tr("INF_APP_DUMP_VIEW"),
-                                              false);
-  if (!fileName.isNull()) {
-    QApplication::setOverrideCursor( Qt::waitCursor );
-    QString fmt = SUIT_Tools::extension( fileName ).upper();
-    if (fmt.isEmpty())
-      fmt = QString("BMP"); // default format
-    if (fmt == "JPG")
-      fmt = "JPEG";
-    bool bOk = px.save(fileName, fmt.latin1());
-    QApplication::restoreOverrideCursor();
-    if (!bOk) {
-      SUIT_MessageBox::error1(this, tr("ERROR"), tr("ERR_DOC_CANT_SAVE_FILE"), tr("BUT_OK"));
-    }
-  }
-}
-
 //----------------------------------------------------------------
 void
 SVTK_ViewWindow
@@ -890,3 +870,12 @@ SVTK_ViewWindow
   RemoveActor(theActor);
   InsertActor(theActor,true);
 }
+
+//----------------------------------------------------------------------------
+QImage
+SVTK_ViewWindow
+::dumpView()
+{
+  QPixmap px = QPixmap::grabWindow( myRenderWindow->winId() );
+  return px.convertToImage();
+}