Salome HOME
Dialog SetupCurveDlg has been added
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewWindow.cxx
index f9065da7ba270657dda1e78925a35634c58b97a7..0351deacd668b655e8ee4a9c138daad5e1f24e35 100755 (executable)
@@ -13,7 +13,6 @@
 
 #include "SUIT_Tools.h"
 #include "SUIT_ResourceMgr.h"
-#include "SUIT_FileDlg.h"
 #include "SUIT_MessageBox.h"
 
 #include <qptrlist.h>
@@ -22,7 +21,7 @@
 #include <qcolor.h>
 #include <qpainter.h>
 #include <qapplication.h>
-
+#include <qdatetime.h>
 
 const char* imageZoomCursor[] = { 
 "32 32 3 1",
@@ -391,7 +390,7 @@ void OCCViewer_ViewWindow::setTransformRequested ( OperationType op )
 }
 
 
-//****************************************************************
+//****************************************************************/
 void OCCViewer_ViewWindow::vpMouseMoveEvent(QMouseEvent* theEvent)
 {
   myCurrX = theEvent->x();
@@ -442,7 +441,7 @@ void OCCViewer_ViewWindow::vpMouseMoveEvent(QMouseEvent* theEvent)
   }
 }
 
-//****************************************************************
+//****************************************************************/
 void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent)
 {
   switch ( myOperation ) {
@@ -523,7 +522,7 @@ void OCCViewer_ViewWindow::resetState()
 }
 
 
-//****************************************************************
+//****************************************************************/
 void OCCViewer_ViewWindow::drawRect()
 {
   QPainter aPainter(myViewPort);
@@ -536,7 +535,7 @@ void OCCViewer_ViewWindow::drawRect()
   myRect = aRect;
 }
 
-//****************************************************************
+//****************************************************************/
 void OCCViewer_ViewWindow::createActions()
 {
   if (!myActionsMap.isEmpty()) return;
@@ -656,12 +655,21 @@ void OCCViewer_ViewWindow::createActions()
   aAction->setStatusTip(tr("DSC_PRESETS_VIEW"));
   connect(aAction, SIGNAL(activated()), this, SLOT(onRestoreView()));
        myActionsMap[ RestoreId ] = aAction;
+
+  if (myModel->trihedronActivated()) {
+    aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TRIHEDRON" ) ),
+                             tr( "MNU_SHOW_TRIHEDRE" ), 0, this);
+    aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRE"));
+    connect(aAction, SIGNAL(activated()), this, SLOT(onTrihedronShow()));
+         myActionsMap[ TrihedronShowId ] = aAction;
+  }
 }
 
 //****************************************************************
 void OCCViewer_ViewWindow::createToolBar()
 {
   myActionsMap[DumpId]->addTo(myToolBar);
+  myActionsMap[TrihedronShowId]->addTo(myToolBar);
 
   SUIT_ToolButton* aScaleBtn = new SUIT_ToolButton(myToolBar, "scale");
   aScaleBtn->AddAction(myActionsMap[FitAllId]);
@@ -767,37 +775,6 @@ void OCCViewer_ViewWindow::onFitAll()
   myViewPort->fitAll();
 }
 
-//****************************************************************
-/*
-   Dumps 3d-Viewer contents into image file
-   File format is defined by file's extension; supported formats : PNG, BMP, GIF, JPG
-*/
-void OCCViewer_ViewWindow::onDumpView()
-{
-  QApplication::setOverrideCursor( Qt::waitCursor );
-  QPixmap px = QPixmap::grabWindow(myViewPort->winId());
-  QApplication::restoreOverrideCursor();
-  
-  QString fileName = SUIT_FileDlg::getFileName(this,
-                                             QString::null,
-                                             tr("OCC_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 OCCViewer_ViewWindow::onCloneView()
 {
@@ -874,3 +851,15 @@ void OCCViewer_ViewWindow::setRestoreFlag()
        myRestoreFlag = 1;
 }
 
+//****************************************************************
+void OCCViewer_ViewWindow::onTrihedronShow()
+{
+  myModel->toggleTrihedron();
+}
+
+//****************************************************************
+QImage OCCViewer_ViewWindow::dumpView()
+{
+  QPixmap px = QPixmap::grabWindow( myViewPort->winId() );
+  return px.convertToImage();
+}