]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
*** empty log message ***
authorstv <stv@opencascade.com>
Tue, 19 Feb 2008 12:05:32 +0000 (12:05 +0000)
committerstv <stv@opencascade.com>
Tue, 19 Feb 2008 12:05:32 +0000 (12:05 +0000)
src/VVTK/VVTK_MainWindow.cxx
src/VVTK/VVTK_MainWindow.h

index d72b7600aab87ae34089c9578906d0fbc056a7f4..32e72a7d61d54d91d0ab0ff45542beeeb2d3a4c2 100644 (file)
@@ -1,29 +1,29 @@
 //  SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
 //
 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
-//  File   : 
-//  Author : 
-//  Module : 
+//  File   :
+//  Author :
+//  Module :
 //  $Header$
 
 #include "VVTK_MainWindow.h"
@@ -32,7 +32,7 @@
 #include "VVTK_RecorderDlg.h"
 #include "VISU_WidgetCtrl.hxx"
 #include "VISU_GaussPtsAct.h"
-#include "VISU_Event.h" 
+#include "VISU_Event.h"
 
 #include "SVTK_ViewWindow.h"
 #include "SVTK_RenderWindowInteractor.h"
 #include "VVTK_PickingDlg.h"
 #include "VVTK_SegmentationCursorDlg.h"
 
-#include "SUIT_Application.h"
-#include "SUIT_Session.h"
-#include "SUIT_Tools.h"
-#include "SUIT_ViewWindow.h"
-#include "SUIT_ResourceMgr.h"
-#include "SUIT_Accel.h"
-#include "SUIT_MessageBox.h"
-#include "QtxAction.h"
-#include "QtxMultiAction.h"
+#include <SUIT_Tools.h>
+#include <SUIT_Accel.h>
+#include <SUIT_Session.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Application.h>
+
+#include <QtxAction.h>
+#include <QtxMultiAction.h>
+#include <QtxActionToolMgr.h>
 
 #include <QImage>
 #include <QToolBar>
@@ -58,7 +60,7 @@
 
 //----------------------------------------------------------------------------
 VVTK_MainWindow
-::VVTK_MainWindow(QWidget* theParent, 
+::VVTK_MainWindow(QWidget* theParent,
                  const char* theName,
                  SUIT_ResourceMgr* theResourceMgr,
                  SUIT_ViewWindow* theViewWindow):
@@ -75,49 +77,63 @@ VVTK_MainWindow
 
   myInteractorStyle->Delete();
 
-  addToolBar( Qt::LeftToolBarArea, myToolBar );
+  if ( getToolBar() )
+    addToolBar( Qt::LeftToolBarArea, getToolBar() );
   //TO DO:
   //myActionsMap[NonIsometric]->removeFrom(myToolBar);
 
+  QtxAction* anAction = 0;
+  QtxActionToolMgr* mgr = myViewWindow->toolMgr();
+
+  // Dump view
+  anAction = new QtxAction(tr("MNU_DUMP_VIEW"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
+                          tr( "MNU_DUMP_VIEW" ), 0, this);
+  anAction->setStatusTip(tr("DSC_DUMP_VIEW"));
+  connect(anAction, SIGNAL(activated()), myViewWindow, SLOT(onDumpView()));
+  mgr->registerAction( anAction, DumpId );
+
   // Recording
-  myRecordingToolBar = new QToolBar(tr("LBL_TOOLBAR_RECORD_LABEL"), this);
-  addToolBar(Qt::LeftToolBarArea, myRecordingToolBar );
+  myRecordingToolBar = mgr->createToolBar( tr( "LBL_TOOLBAR_RECORD_LABEL" ) );
+  addToolBar( Qt::LeftToolBarArea, mgr->toolBar( myRecordingToolBar ) );
 
-  myStartAction = new QtxAction(tr("MNU_VVTK_RECORDING_START"), 
+  myStartAction = new QtxAction(tr("MNU_VVTK_RECORDING_START"),
                                theResourceMgr->loadPixmap( "VISU", tr( "ICON_VVTK_RECORDING_START" ) ),
                                tr( "MNU_VVTK_RECORDING_START" ), 0, this);
   myStartAction->setStatusTip(tr("DSC_VVTK_RECORDING_START"));
-  //myStartAction->addTo( myRecordingToolBar );
-  myRecordingToolBar->addAction( myStartAction  );
   connect( myStartAction, SIGNAL( triggered ( bool ) ), this, SLOT( OnStartRecording() ) );
+  mgr->append( myStartAction, myRecordingToolBar );
 
-  myPlayAction = new QtxAction(tr("MNU_VVTK_RECORDING_PLAY"), 
+  myPlayAction = new QtxAction(tr("MNU_VVTK_RECORDING_PLAY"),
                               theResourceMgr->loadPixmap( "VISU", tr( "ICON_VVTK_RECORDING_PLAY" ) ),
                               tr( "MNU_VVTK_RECORDING_PLAY" ), 0, this);
   myPlayAction->setStatusTip(tr("DSC_VVTK_RECORDING_PLAY"));
   myPlayAction->setEnabled( false );
   //myPlayAction->addTo( myRecordingToolBar );
-  myRecordingToolBar->addAction( myPlayAction  );
+  //  myRecordingToolBar->addAction( myPlayAction  );
+  mgr->append( myPlayAction, myRecordingToolBar );
   connect( myPlayAction, SIGNAL( triggered ( bool ) ), this, SLOT( OnPlayRecording() ) );
 
-  myPauseAction = new QtxAction(tr("MNU_VVTK_RECORDING_PAUSE"), 
+  myPauseAction = new QtxAction(tr("MNU_VVTK_RECORDING_PAUSE"),
                                theResourceMgr->loadPixmap( "VISU", tr( "ICON_VVTK_RECORDING_PAUSE" ) ),
                                tr( "MNU_VVTK_RECORDING_PAUSE" ), 0, this);
   myPauseAction->setStatusTip(tr("DSC_VVTK_RECORDING_PAUSE"));
   myPauseAction->setEnabled( false );
   //myPauseAction->addTo( myRecordingToolBar );
-  myRecordingToolBar->addAction( myPauseAction  );
+  //myRecordingToolBar->addAction( myPauseAction  );
+  mgr->append( myPauseAction, myRecordingToolBar );
   connect( myPauseAction, SIGNAL( triggered ( bool ) ), this, SLOT( OnPauseRecording() ) );
 
-  myStopAction = new QtxAction(tr("MNU_VVTK_RECORDING_STOP"), 
+  myStopAction = new QtxAction(tr("MNU_VVTK_RECORDING_STOP"),
                               theResourceMgr->loadPixmap( "VISU", tr( "ICON_VVTK_RECORDING_STOP" ) ),
                               tr( "MNU_VVTK_RECORDING_STOP" ), 0, this);
   myStopAction->setStatusTip(tr("DSC_VVTK_RECORDING_STOP"));
   myStopAction->setEnabled( false );
   //myStopAction->addTo( myRecordingToolBar );
-  myRecordingToolBar->addAction( myStopAction  );
+  //myRecordingToolBar->addAction( myStopAction  );
+  mgr->append( myStopAction, myRecordingToolBar );
   connect( myStopAction, SIGNAL( triggered ( bool ) ), this, SLOT( OnStopRecording() ) );
-  
+
   myRecorder = VVTK_Recorder::New();
   //myRecorder->CheckExistAVIMaker();
   //if(myRecorder->ErrorStatus())
@@ -128,7 +144,7 @@ VVTK_MainWindow
 void
 VVTK_MainWindow
 ::Initialize(SVTK_RenderWindowInteractor* theInteractor)
-{ 
+{
   vtkInteractorStyle* aStyle = theInteractor->GetInteractorStyle();
   if(SVTK_InteractorStyle *anInteractorStyle = dynamic_cast<SVTK_InteractorStyle*>(aStyle)){
     anInteractorStyle->SetControllerIncrement(myControllerIncrement.GetPointer());
@@ -141,18 +157,18 @@ VVTK_MainWindow
   myRecorder->SetUseSkippedFrames(true);
   myRecorder->SetRenderWindow(theInteractor->getRenderWindow());
 
-  disconnect( myActionsMap[ DumpId ], SIGNAL( activated() ),
-             myViewWindow, SLOT( onDumpView() ) );
-
-  connect( myActionsMap[ DumpId ], SIGNAL( activated() ),
-          this, SLOT( onDumpView() ) );
+  if ( myViewWindow->toolMgr()->action( DumpId ) )
+  {
+    disconnect( myViewWindow->toolMgr()->action( DumpId ), SIGNAL( activated() ), myViewWindow, SLOT( onDumpView() ) );
+    connect( myViewWindow->toolMgr()->action( DumpId ), SIGNAL( activated() ), this, SLOT( onDumpView() ) );
+  }
 
   SVTK_MainWindow::Initialize(theInteractor);
 }
 
 VVTK_MainWindow::~VVTK_MainWindow()
 {
-  if(myRecorder)
+  if ( myRecorder )
     myRecorder->Delete();
 }
 
@@ -161,7 +177,7 @@ void VVTK_MainWindow::onDumpView()
 {
   QImage img = dumpView();
   if( img.isNull() )
-    return; 
+    return;
 
   SUIT_Application* app = SUIT_Session::session()->activeApplication();
   QString fileName = app->getFileName( false, QString::null,
@@ -248,7 +264,7 @@ void VVTK_MainWindow::OnStopRecording()
 }
 
 //----------------------------------------------------------------------------
-void 
+void
 VVTK_MainWindow
 ::action( const int accelAction  )
 {
@@ -262,7 +278,7 @@ VVTK_MainWindow
 
 //----------------------------------------------------------------------------
 VVTK_MainWindow1
-::VVTK_MainWindow1(QSplitter* theParent, 
+::VVTK_MainWindow1(QSplitter* theParent,
                  const char* theName,
                  SUIT_ResourceMgr* theResourceMgr,
                  SUIT_ViewWindow* theViewWindow):
@@ -278,12 +294,12 @@ VVTK_MainWindow1
   QtxAction* anAction;
 
   aPixmap = theResourceMgr->loadPixmap( "VISU", tr( "ICON_VVTK_INTERACTOR_STYLE_SWITCH" ) );
-  anAction = new QtxAction(tr("MNU_VVTK_INTERACTOR_STYLE_SWITCH"), 
+  anAction = new QtxAction(tr("MNU_VVTK_INTERACTOR_STYLE_SWITCH"),
                           aPixmap,
-                          tr( "MNU_VVTK_INTERACTOR_STYLE_SWITCH" ), 
-                          0, 
-                          this, 
-                          //"VVTK/SVTK StyleSwitch", 
+                          tr( "MNU_VVTK_INTERACTOR_STYLE_SWITCH" ),
+                          0,
+                          this,
+                          //"VVTK/SVTK StyleSwitch",
                           true);
   anAction->setCheckable(true);
   anAction->setStatusTip(tr("DSC_VVTK_INTERACTOR_STYLE_SWITCH"));
@@ -295,12 +311,12 @@ VVTK_MainWindow1
     myStyleSwitchAction->toggle();
 
   aPixmap = theResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_SELECTION_MODE_SWITCH"));
-  myPickingAction = new QtxAction(tr("MNU_VVTK_SELECTION_MODE_SWITCH"), 
+  myPickingAction = new QtxAction(tr("MNU_VVTK_SELECTION_MODE_SWITCH"),
                                  aPixmap,
-                                 tr( "MNU_VVTK_SELECTION_MODE_SWITCH" ), 
-                                 0, 
-                                 this, 
-                                 //"VVTK/SVTK SelectionSwitch", 
+                                 tr( "MNU_VVTK_SELECTION_MODE_SWITCH" ),
+                                 0,
+                                 this,
+                                 //"VVTK/SVTK SelectionSwitch",
                                  true);
   myPickingAction->setCheckable(true);
   myPickingAction->setStatusTip(tr("DSC_VVTK_SELECTION_MODE_SWITCH"));
@@ -311,12 +327,12 @@ VVTK_MainWindow1
 
   // Plane/Sphere Segmentation
   aPixmap = theResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_PLANE_SEGMENTATION_SWITCH"));
-  myPlaneSegmentationAction = new QtxAction(tr("MNU_VVTK_PLANE_SEGMENTATION_SWITCH"), 
+  myPlaneSegmentationAction = new QtxAction(tr("MNU_VVTK_PLANE_SEGMENTATION_SWITCH"),
                                            aPixmap,
-                                           tr( "MNU_VVTK_PLANE_SEGMENTATION_SWITCH" ), 
-                                           0, 
-                                           this, 
-                                           //"VVTK/SVTK PlaneSegmentationSwitch", 
+                                           tr( "MNU_VVTK_PLANE_SEGMENTATION_SWITCH" ),
+                                           0,
+                                           this,
+                                           //"VVTK/SVTK PlaneSegmentationSwitch",
                                            true);
   myPlaneSegmentationAction->setCheckable(true);
   myPlaneSegmentationAction->setStatusTip(tr("DSC_VVTK_PLANE_SEGMENTATION_SWITCH"));
@@ -324,12 +340,12 @@ VVTK_MainWindow1
   connect( myPlaneSegmentationAction, SIGNAL( triggered() ), this, SLOT( OnSegmentationSwitch() ) );
 
   aPixmap = theResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_SPHERE_SEGMENTATION_SWITCH"));
-  mySphereSegmentationAction = new QtxAction(tr("MNU_VVTK_SPHERE_SEGMENTATION_SWITCH"), 
+  mySphereSegmentationAction = new QtxAction(tr("MNU_VVTK_SPHERE_SEGMENTATION_SWITCH"),
                                             aPixmap,
-                                            tr( "MNU_VVTK_SPHERE_SEGMENTATION_SWITCH" ), 
-                                            0, 
-                                            this, 
-                                            //"VVTK/SVTK SphereSegmentationSwitch", 
+                                            tr( "MNU_VVTK_SPHERE_SEGMENTATION_SWITCH" ),
+                                            0,
+                                            this,
+                                            //"VVTK/SVTK SphereSegmentationSwitch",
                                             true);
   mySphereSegmentationAction->setCheckable(true);
   mySphereSegmentationAction->setStatusTip(tr("DSC_VVTK_SPHERE_SEGMENTATION_SWITCH"));
@@ -374,7 +390,7 @@ VVTK_MainWindow1
 //----------------------------------------------------------------------------
 VVTK_MainWindow2*
 VVTK_MainWindow1
-::CreateMainWindow2(QWidget* theParent, 
+::CreateMainWindow2(QWidget* theParent,
                    const char* theName,
                    SUIT_ResourceMgr* theResourceMgr,
                    SUIT_ViewWindow* theViewWindow)
@@ -395,7 +411,7 @@ VVTK_MainWindow1
 {
   if ( theIsSelectionOn && !isVisible() )
     return;
-  
+
   Selection_Mode aSelectionMode = SelectionMode();
   if(theIsSelectionOn && aSelectionMode != GaussPointSelection)
     SetSelectionMode(GaussPointSelection);
@@ -424,28 +440,28 @@ VVTK_MainWindow1
 
 
 //----------------------------------------------------------------------------
-VISU_WidgetCtrl* 
+VISU_WidgetCtrl*
 VVTK_MainWindow1
 ::GetWidgetCtrl()
 {
   return myRenderer->GetWidgetCtrl();
 }
 
-VISU_InsideCursorSettings* 
+VISU_InsideCursorSettings*
 VVTK_MainWindow1
 ::GetInsideCursorSettings()
 {
   return mySegmentationCursorDlg->GetInsideCursorSettings();
 }
 
-VISU_OutsideCursorSettings* 
+VISU_OutsideCursorSettings*
 VVTK_MainWindow1
 ::GetOutsideCursorSettings()
 {
   return mySegmentationCursorDlg->GetOutsideCursorSettings();
 }
 
-VISU_PickingSettings* 
+VISU_PickingSettings*
 VVTK_MainWindow1
 ::GetPickingSettings()
 {
@@ -478,9 +494,9 @@ VVTK_MainWindow1
 
   if( !theAction )
     return;
-  
+
   VISU_WidgetCtrl *aWidgetCtrl = myRenderer->GetWidgetCtrl();
-  
+
   if (anIsSegmentationOn) {
     int anIndex = (theAction == myPlaneSegmentationAction) ? 0 : 1;
     aWidgetCtrl->SetActiveIndex(anIndex);
@@ -519,7 +535,7 @@ VVTK_MainWindow1
 
 //----------------------------------------------------------------------------
 VVTK_MainWindow2
-::VVTK_MainWindow2(QWidget* theParent, 
+::VVTK_MainWindow2(QWidget* theParent,
                   const char* theName,
                   SUIT_ResourceMgr* theResourceMgr,
                   SUIT_ViewWindow* theViewWindow,
index dc440807467778a6007e7e8dd82348c66079b5ec..87d1b3ab7a6f7d58fb642e8c8684037f3da4681f 100644 (file)
@@ -101,7 +101,7 @@ public:
   vtkSmartPointer<VVTK_ControllerIncrement> myControllerIncrement;
   vtkSmartPointer<VVTK_ControllerOnKeyDown> myControllerOnKeyDown; 
 
-  QToolBar* myRecordingToolBar;
+  int        myRecordingToolBar;
   QtxAction* myStartAction;
   QtxAction* myPlayAction;
   QtxAction* myPauseAction;