From 4f71f161ef63928eb4268c61e8bb1ef5e7915322 Mon Sep 17 00:00:00 2001 From: asl Date: Mon, 28 Apr 2008 12:53:13 +0000 Subject: [PATCH] fix for PAL19420: as temporary solution, the functionality using tool manager mechanism has been rolled back and now usual QToolBars are used --- src/VVTK/VVTK_MainWindow.cxx | 195 +++++++++++++++++------------------ src/VVTK/VVTK_MainWindow.h | 5 +- 2 files changed, 97 insertions(+), 103 deletions(-) diff --git a/src/VVTK/VVTK_MainWindow.cxx b/src/VVTK/VVTK_MainWindow.cxx index 6ad3dbb7..456b2715 100644 --- a/src/VVTK/VVTK_MainWindow.cxx +++ b/src/VVTK/VVTK_MainWindow.cxx @@ -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" @@ -40,17 +40,16 @@ #include "VVTK_PickingDlg.h" #include "VVTK_SegmentationCursorDlg.h" -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#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 "QtxActionToolMgr.h" #include #include @@ -60,7 +59,7 @@ //---------------------------------------------------------------------------- VVTK_MainWindow -::VVTK_MainWindow(QWidget* theParent, +::VVTK_MainWindow(QWidget* theParent, const char* theName, SUIT_ResourceMgr* theResourceMgr, SUIT_ViewWindow* theViewWindow): @@ -69,6 +68,7 @@ VVTK_MainWindow myControllerIncrement(VVTK_ControllerIncrement::New()), myControllerOnKeyDown(VVTK_ControllerOnKeyDown::New()) { + myToolMgr = new QtxActionToolMgr( this ); myInteractorStyle->SetControllerIncrement(myControllerIncrement.GetPointer()); myControllerIncrement->Delete(); @@ -77,75 +77,65 @@ VVTK_MainWindow myInteractorStyle->Delete(); - if ( getToolBar() ) - addToolBar( Qt::LeftToolBarArea, getToolBar() ); - - QtxAction* anAction = 0; - QtxActionToolMgr* mgr = myViewWindow->toolMgr(); - - //myActionsMap[NonIsometric]->removeFrom(myToolBar); - mgr->remove(NonIsometric, myToolBar); - - // 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 = mgr->createToolBar( tr( "LBL_TOOLBAR_RECORD_LABEL" ), -1, this); - addToolBar( Qt::LeftToolBarArea, mgr->toolBar( myRecordingToolBar ) ); + myRecordingToolBar = new QToolBar(tr("LBL_TOOLBAR_RECORD_LABEL"), this); + addToolBar(Qt::LeftToolBarArea, myRecordingToolBar ); + myViewWindow->toolMgr()->remove( NonIsometric, myToolBar ); + - 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 ); - mgr->append( myPlayAction, myRecordingToolBar ); + myRecordingToolBar->addAction( myPlayAction ); 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 ); - mgr->append( myPauseAction, myRecordingToolBar ); + myRecordingToolBar->addAction( myPauseAction ); 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 ); - mgr->append( myStopAction, myRecordingToolBar ); + myRecordingToolBar->addAction( myStopAction ); connect( myStopAction, SIGNAL( triggered ( bool ) ), this, SLOT( OnStopRecording() ) ); - + myRecorder = VVTK_Recorder::New(); //myRecorder->CheckExistAVIMaker(); //if(myRecorder->ErrorStatus()) // myRecordingToolBar->setEnabled(false); } +//---------------------------------------------------------------------------- + +QtxActionToolMgr* VVTK_MainWindow::toolMgr() const +{ + return myToolMgr; +} + //---------------------------------------------------------------------------- void VVTK_MainWindow ::Initialize(SVTK_RenderWindowInteractor* theInteractor) -{ +{ vtkInteractorStyle* aStyle = theInteractor->GetInteractorStyle(); if(SVTK_InteractorStyle *anInteractorStyle = dynamic_cast(aStyle)){ anInteractorStyle->SetControllerIncrement(myControllerIncrement.GetPointer()); @@ -158,18 +148,19 @@ VVTK_MainWindow myRecorder->SetUseSkippedFrames(true); myRecorder->SetRenderWindow(theInteractor->getRenderWindow()); - 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() ) ); - } + disconnect( SVTK_MainWindow::action( DumpId ), SIGNAL( activated() ), + myViewWindow, SLOT( onDumpView() ) ); + + connect( SVTK_MainWindow::action( DumpId ), SIGNAL( activated() ), + this, SLOT( onDumpView() ) ); SVTK_MainWindow::Initialize(theInteractor); + addToolBar( Qt::LeftToolBarArea, getToolBar() ); } VVTK_MainWindow::~VVTK_MainWindow() { - if ( myRecorder ) + if(myRecorder) myRecorder->Delete(); } @@ -178,7 +169,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, @@ -265,7 +256,7 @@ void VVTK_MainWindow::OnStopRecording() } //---------------------------------------------------------------------------- -void +void VVTK_MainWindow ::action( const int accelAction ) { @@ -279,7 +270,7 @@ VVTK_MainWindow //---------------------------------------------------------------------------- VVTK_MainWindow1 -::VVTK_MainWindow1(QSplitter* theParent, +::VVTK_MainWindow1(QSplitter* theParent, const char* theName, SUIT_ResourceMgr* theResourceMgr, SUIT_ViewWindow* theViewWindow): @@ -295,12 +286,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")); @@ -312,12 +303,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")); @@ -328,12 +319,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")); @@ -341,12 +332,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")); @@ -391,7 +382,7 @@ VVTK_MainWindow1 //---------------------------------------------------------------------------- VVTK_MainWindow2* VVTK_MainWindow1 -::CreateMainWindow2(QWidget* theParent, +::CreateMainWindow2(QWidget* theParent, const char* theName, SUIT_ResourceMgr* theResourceMgr, SUIT_ViewWindow* theViewWindow) @@ -412,7 +403,7 @@ VVTK_MainWindow1 { if ( theIsSelectionOn && !isVisible() ) return; - + Selection_Mode aSelectionMode = SelectionMode(); if(theIsSelectionOn && aSelectionMode != GaussPointSelection) SetSelectionMode(GaussPointSelection); @@ -441,28 +432,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() { @@ -495,9 +486,9 @@ VVTK_MainWindow1 if( !theAction ) return; - + VISU_WidgetCtrl *aWidgetCtrl = myRenderer->GetWidgetCtrl(); - + if (anIsSegmentationOn) { int anIndex = (theAction == myPlaneSegmentationAction) ? 0 : 1; aWidgetCtrl->SetActiveIndex(anIndex); @@ -536,7 +527,7 @@ VVTK_MainWindow1 //---------------------------------------------------------------------------- VVTK_MainWindow2 -::VVTK_MainWindow2(QWidget* theParent, +::VVTK_MainWindow2(QWidget* theParent, const char* theName, SUIT_ResourceMgr* theResourceMgr, SUIT_ViewWindow* theViewWindow, diff --git a/src/VVTK/VVTK_MainWindow.h b/src/VVTK/VVTK_MainWindow.h index 87d1b3ab..24718220 100644 --- a/src/VVTK/VVTK_MainWindow.h +++ b/src/VVTK/VVTK_MainWindow.h @@ -97,17 +97,20 @@ public: OnStopRecording(); protected: + virtual QtxActionToolMgr* toolMgr() const; + vtkSmartPointer myInteractorStyle; vtkSmartPointer myControllerIncrement; vtkSmartPointer myControllerOnKeyDown; - int myRecordingToolBar; + QToolBar* myRecordingToolBar; QtxAction* myStartAction; QtxAction* myPlayAction; QtxAction* myPauseAction; QtxAction* myStopAction; VVTK_Recorder *myRecorder; + QtxActionToolMgr* myToolMgr; }; -- 2.39.2