From 56f28ed9755fc8a0e62c841542f180f5ea228d2d Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 12 Sep 2005 05:02:18 +0000 Subject: [PATCH] To introduce segmentation functionality --- src/Makefile.in | 2 +- src/VISUGUI/VISUM_images.po | 6 + src/VISUGUI/VISUM_msg_en.po | 14 ++- src/VISUGUI/VisuGUI_Module.cxx | 18 ++- src/VVTK/Makefile.in | 1 + src/VVTK/VVTK_Renderer.cxx | 193 +++++++++++++++++++++++++++++++++ src/VVTK/VVTK_Renderer.h | 110 +++++++++++++++++++ src/VVTK/VVTK_View.cxx | 154 ++++++++++++++++---------- src/VVTK/VVTK_View.h | 62 ++++++++--- src/VVTK/VVTK_ViewWindow.cxx | 97 +++++++++++++++-- src/VVTK/VVTK_ViewWindow.h | 28 ++++- 11 files changed, 592 insertions(+), 93 deletions(-) create mode 100644 src/VVTK/VVTK_Renderer.cxx create mode 100644 src/VVTK/VVTK_Renderer.h diff --git a/src/Makefile.in b/src/Makefile.in index c9211e43..7e207ca1 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -32,6 +32,6 @@ VPATH=.:@srcdir@ @COMMENCE@ -SUBDIRS = CONVERTOR PIPELINE OBJECT ENGINE VVTK GUITOOLS VISU_I VISUGUI VISU_SWIG +SUBDIRS = CONVERTOR PIPELINE OBJECT VVTK GUITOOLS VISU_I VISUGUI VISU_SWIG ENGINE @MODULE@ diff --git a/src/VISUGUI/VISUM_images.po b/src/VISUGUI/VISUM_images.po index 647fb721..e07995e9 100644 --- a/src/VISUGUI/VISUM_images.po +++ b/src/VISUGUI/VISUM_images.po @@ -33,11 +33,17 @@ msgstr "" "Content-Type: text/plain; charset=iso-8859-1\n" +msgid "ICON_GAUSS_NEW_VIEWER" +msgstr "Visu_points.png" + msgid "ICON_VVTK_INTERACTOR_STYLE_SWITCH" msgstr "Visu_vvtk_switch.png" msgid "ICON_VVTK_SELECTION_MODE_SWITCH" msgstr "Visu_points.png" +msgid "ICON_VVTK_PLANE_SEGMENTATION_SWITCH" +msgstr "Visu_PlaneSegmentation.png" + msgid "ICON_LOAD_TEXTURE" msgstr "Visu_load_texture.png" diff --git a/src/VISUGUI/VISUM_msg_en.po b/src/VISUGUI/VISUM_msg_en.po index f1d76887..73c4800a 100644 --- a/src/VISUGUI/VISUM_msg_en.po +++ b/src/VISUGUI/VISUM_msg_en.po @@ -102,18 +102,24 @@ msgstr "Gauss Points Properties" msgid "VVTK_ViewManager::VTK_VIEW_TITLE" msgstr "VISU scene:%1 - viewer:%2" -msgid "VVTK_ViewWindow::MNU_VVTK_INTERACTOR_STYLE_SWITCH" +msgid "VVTK_MainWindowBase::MNU_VVTK_INTERACTOR_STYLE_SWITCH" msgstr "Interaction Style Switch" -msgid "VVTK_ViewWindow::DSC_VVTK_INTERACTOR_STYLE_SWITCH" +msgid "VVTK_MainWindowBase::DSC_VVTK_INTERACTOR_STYLE_SWITCH" msgstr "Interaction Style Switch" -msgid "VVTK_ViewWindow::MNU_VVTK_SELECTION_MODE_SWITCH" +msgid "VVTK_MainWindowBase::MNU_VVTK_SELECTION_MODE_SWITCH" msgstr "Selection Mode Switch" -msgid "VVTK_ViewWindow::DSC_VVTK_SELECTION_MODE_SWITCH" +msgid "VVTK_MainWindowBase::DSC_VVTK_SELECTION_MODE_SWITCH" msgstr "Selection Mode Switch" +msgid "VVTK_MainWindow::MNU_VVTK_PLANE_SEGMENTATION_SWITCH" +msgstr "Plane Segmentation Switch" + +msgid "VVTK_MainWindow::DSC_VVTK_PLANE_SEGMENTATION_SWITCH" +msgstr "Plane Segmentation Switch" + msgid "VisuGUI_GaussPointsDlg::&Cancel" msgstr "" diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index 89cdc342..7c990d61 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -165,10 +165,20 @@ VisuGUI_Module { VisuGUI::initialize( theApp ); - // create actions and add menus - createAction( GAUSS_NEW_VIEWER, tr("MEN_GAUSS_NEW_VIEWER"), QIconSet(), - tr("MEN_GAUSS_NEW_VIEWER"), "", 0, this, false, - this, SLOT(onCreateViewManager())); + SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); + + QPixmap aPixmap; + aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GAUSS_NEW_VIEWER")); + createAction( GAUSS_NEW_VIEWER, + tr("MEN_GAUSS_NEW_VIEWER"), + aPixmap, + tr("MEN_GAUSS_NEW_VIEWER"), + tr("MEN_GAUSS_NEW_VIEWER"), + ALT+Key_S, + this, + false, + this, + SLOT(onCreateViewManager())); int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 ); int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 ); int gaussMenu = createMenu( action( GAUSS_NEW_VIEWER ), newWinMenu, -1 ); diff --git a/src/VVTK/Makefile.in b/src/VVTK/Makefile.in index 0f36b64c..6ebf0a3d 100755 --- a/src/VVTK/Makefile.in +++ b/src/VVTK/Makefile.in @@ -26,6 +26,7 @@ LIB_SRC= VVTK_ViewManager.cxx \ VVTK_ViewModel.cxx \ VVTK_InteractorStyle.cxx \ VVTK_ViewWindow.cxx \ + VVTK_Renderer.cxx \ VVTK_View.cxx LIB_MOC = VVTK_ViewWindow.h \ diff --git a/src/VVTK/VVTK_Renderer.cxx b/src/VVTK/VVTK_Renderer.cxx new file mode 100644 index 00000000..09e7f95f --- /dev/null +++ b/src/VVTK/VVTK_Renderer.cxx @@ -0,0 +1,193 @@ +// SALOME VTKViewer : build VTK viewer into Salome desktop +// +// 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 +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : +// Author : +// Module : +// $Header$ + +#include "VVTK_Renderer.h" + +#include "VISU_GaussPtsAct.h" + +#include +#include +#include + +#include +#include +#include +#include + +#include "utilities.h" + +#ifdef _DEBUG_ +static int MYDEBUG = 1; +#else +static int MYDEBUG = 0; +#endif + + +//---------------------------------------------------------------------------- +vtkStandardNewMacro(VVTK_Renderer1); + +//---------------------------------------------------------------------------- +VVTK_Renderer1 +::VVTK_Renderer1(): + myImplicitPlaneWidget(vtkImplicitPlaneWidget::New()) +{ + if(MYDEBUG) INFOS("VVTK_Renderer1() - "<SetPlaceFactor(1.0); + myImplicitPlaneWidget->SetOutlineTranslation(false); + vtkProperty* aSelectedPlaneProperty = myImplicitPlaneWidget->GetSelectedPlaneProperty(); + vtkProperty* aPlaneProperty = myImplicitPlaneWidget->GetPlaneProperty(); + aPlaneProperty->SetOpacity(aSelectedPlaneProperty->GetOpacity()*1.5); + + myImplicitPlaneWidget->Delete(); +} + +VVTK_Renderer1 +::~VVTK_Renderer1() +{ + if(MYDEBUG) INFOS("~VVTK_Renderer1() - "<SetInteractor(NULL); +} + +//---------------------------------------------------------------------------- +void +VVTK_Renderer1 +::SetInteractor(vtkRenderWindowInteractor* theInteractor) +{ + SVTK_Renderer::SetInteractor(theInteractor); + myImplicitPlaneWidget->SetInteractor(theInteractor); +} + +//---------------------------------------------------------------------------- +vtkImplicitPlaneWidget* +VVTK_Renderer1 +::GetImplicitPlaneWidget() +{ + return myImplicitPlaneWidget.GetPointer(); +} + +//---------------------------------------------------------------------------- +bool +VVTK_Renderer1 +::OnAdjustActors() +{ + if(SVTK_Renderer::OnAdjustActors()){ + myImplicitPlaneWidget->PlaceWidget(myBndBox); + myImplicitPlaneWidget->SetOrigin((myBndBox[1] + myBndBox[0]) / 2.0, + (myBndBox[3] + myBndBox[2]) / 2.0, + (myBndBox[5] + myBndBox[4]) / 2.0); + myImplicitPlaneWidget->SetHandleSize(myImplicitPlaneWidget->GetHandleSize()); + return true; + } + return false; +} + + +//---------------------------------------------------------------------------- +vtkStandardNewMacro(VVTK_Renderer2); + +//---------------------------------------------------------------------------- +VVTK_Renderer2 +::VVTK_Renderer2(): + myEventCallbackCommand(vtkCallbackCommand::New()), + myFunction(vtkPlane::New()) +{ + if(MYDEBUG) INFOS("VVTK_Renderer2() - "<Delete(); + myFunction->Delete(); + + myPriority = 0.0; + myEventCallbackCommand->SetClientData(this); + myEventCallbackCommand->SetCallback(VVTK_Renderer2::ProcessEvents); +} + +VVTK_Renderer2 +::~VVTK_Renderer2() +{ + if(MYDEBUG) INFOS("~VVTK_Renderer2() - "<GetImplicitPlaneWidget(); + myImplicitPlaneWidget1->AddObserver(vtkCommand::EndInteractionEvent, + myEventCallbackCommand.GetPointer(), + myPriority); + +} + +void +VVTK_Renderer2 +::ProcessEvents(vtkObject* vtkNotUsed(theObject), + unsigned long theEvent, + void* theClientData, + void* vtkNotUsed(theCallData)) +{ + VVTK_Renderer2* self = reinterpret_cast(theClientData); + + switch(theEvent){ + case vtkCommand::EndInteractionEvent: + self->OnEndInteractionEvent(); + break; + } +} + +void +VVTK_Renderer2 +::OnEndInteractionEvent() +{ + myImplicitPlaneWidget1->GetPlane(myFunction.GetPointer()); + myInteractor->Render(); +} + + +//---------------------------------------------------------------------------- +void +VVTK_Renderer2 +::AddActor(VTKViewer_Actor* theActor) +{ + SVTK_Renderer::AddActor(theActor); + if(VISU_Actor* anActor = dynamic_cast(theActor)) + if(VISU::TActorFactory* aFactory = anActor->GetFactory()) + aFactory->AddClippingPlane(anActor,myFunction.GetPointer()); +} + +//---------------------------------------------------------------------------- +void +VVTK_Renderer2 +::RemoveActor(VTKViewer_Actor* theActor) +{ + SVTK_Renderer::RemoveActor(theActor); + if(VISU_Actor* anActor = dynamic_cast(theActor)) + if(VISU::TActorFactory* aFactory = anActor->GetFactory()) + aFactory->RemoveAllClippingPlanes(anActor); +} diff --git a/src/VVTK/VVTK_Renderer.h b/src/VVTK/VVTK_Renderer.h new file mode 100644 index 00000000..19251827 --- /dev/null +++ b/src/VVTK/VVTK_Renderer.h @@ -0,0 +1,110 @@ +// SALOME VTKViewer : build VTK viewer into Salome desktop +// +// 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 +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : +// Author : +// Module : SALOME +// $Header$ + +#ifndef VVTK_Renderer_h +#define VVTK_Renderer_h + +#include "VVTK.h" + +#include "SVTK_Renderer.h" + +class vtkImplicitPlaneWidget; +class vtkPlane; + +//---------------------------------------------------------------------------- +class VVTK_EXPORT VVTK_Renderer1 : public SVTK_Renderer +{ + public: + vtkTypeMacro(VVTK_Renderer1,SVTK_Renderer); + static VVTK_Renderer1* New(); + + virtual + void + SetInteractor(vtkRenderWindowInteractor* theInteractor); + + vtkImplicitPlaneWidget* + GetImplicitPlaneWidget(); + + protected: + VVTK_Renderer1(); + ~VVTK_Renderer1(); + + virtual + bool + OnAdjustActors(); + + vtkSmartPointer myImplicitPlaneWidget; +}; + + +//---------------------------------------------------------------------------- +class VVTK_EXPORT VVTK_Renderer2 : public SVTK_Renderer +{ + public: + vtkTypeMacro(VVTK_Renderer2,SVTK_Renderer); + static VVTK_Renderer2* New(); + + virtual + void + AddActor(VTKViewer_Actor* theActor); + + virtual + void + RemoveActor(VTKViewer_Actor* theActor); + + void + SetRenderer1(VVTK_Renderer1* theRenderer); + + void + OnEndInteractionEvent(); + + protected: + VVTK_Renderer2(); + ~VVTK_Renderer2(); + + // Main process VTK event method + static + void + ProcessEvents(vtkObject* theObject, + unsigned long theEvent, + void* theClientData, + void* theCallData); + + // Used to process VTK events + vtkSmartPointer myEventCallbackCommand; + + // Priority at which events are processed + float myPriority; + + vtkSmartPointer myImplicitPlaneWidget1; + vtkSmartPointer myRenderer1; + vtkSmartPointer myFunction; +}; + + +#endif diff --git a/src/VVTK/VVTK_View.cxx b/src/VVTK/VVTK_View.cxx index 29c4bb2f..a38065d8 100644 --- a/src/VVTK/VVTK_View.cxx +++ b/src/VVTK/VVTK_View.cxx @@ -30,18 +30,19 @@ #include "VVTK_InteractorStyle.h" #include "SVTK_RenderWindowInteractor.h" -#include "SVTK_Renderer.h" +#include "VVTK_Renderer.h" #include "SUIT_ResourceMgr.h" #include "QtxAction.h" #include +#include //---------------------------------------------------------------------------- -VVTK_MainWindow -::VVTK_MainWindow(QWidget* theParent, - const char* theName, - SUIT_ResourceMgr* theResourceMgr): +VVTK_MainWindowBase +::VVTK_MainWindowBase(QWidget* theParent, + const char* theName, + SUIT_ResourceMgr* theResourceMgr): SVTK_MainWindow(theParent,theName,theResourceMgr), myInteractorStyle(VVTK_InteractorStyle::New()) { @@ -64,10 +65,10 @@ VVTK_MainWindow this, "VVTK/SVTK StyleSwitch", true); - anAction->toggle(); anAction->setToggleAction(true); + anAction->toggle(); anAction->setStatusTip(tr("DSC_VVTK_INTERACTOR_STYLE_SWITCH")); - connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onInteractorStyleSwitch(bool))); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(OnInteractorStyleSwitch(bool))); anAction->addTo( myPtsToolBar ); aPixmap = theResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_SELECTION_MODE_SWITCH")); @@ -80,29 +81,92 @@ VVTK_MainWindow true); anAction->setToggleAction(true); anAction->setStatusTip(tr("DSC_VVTK_SELECTION_MODE_SWITCH")); - connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSelectionModeSwitch(bool))); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(OnSelectionModeSwitch(bool))); anAction->addTo( myPtsToolBar ); } void -VVTK_MainWindow -::Initialize() +VVTK_MainWindowBase +::Initialize(SVTK_Renderer *theRenderer) { - SVTK_MainWindow::Initialize(); - - // important! : the default interactor style which is pushed is VVTK - // see onInteractorStyleSwitch() for details + SVTK_MainWindow::Initialize(theRenderer); PushInteractorStyle(myInteractorStyle.GetPointer()); } -VVTK_MainWindow -::~VVTK_MainWindow() +VVTK_MainWindowBase +::~VVTK_MainWindowBase() {} +//---------------------------------------------------------------------------- +void +VVTK_MainWindowBase +::OnInteractorStyleSwitch(bool theIsGaussStyleOn) +{ + if ( theIsGaussStyleOn ) + this->PushInteractorStyle(myInteractorStyle.GetPointer()); + else + this->PopInteractorStyle(); +} + +//---------------------------------------------------------------------------- +void +VVTK_MainWindowBase +::OnSelectionModeSwitch(bool theIsSelectionOn) +{ + SetSelectionMode(theIsSelectionOn? NodeSelection: ActorSelection); +} + + +//---------------------------------------------------------------------------- +VVTK_MainWindow1 +::VVTK_MainWindow1(QWidget* theParent, + const char* theName, + SUIT_ResourceMgr* theResourceMgr): + VVTK_MainWindowBase(theParent,theName,theResourceMgr) +{ + QPixmap aPixmap; + QtxAction* anAction; + + aPixmap = theResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_PLANE_SEGMENTATION_SWITCH")); + anAction = new QtxAction(tr("MNU_VVTK_PLANE_SEGMENTATION_SWITCH"), + aPixmap, + tr( "MNU_VVTK_PLANE_SEGMENTATION_SWITCH" ), + 0, + this, + "VVTK/SVTK PlaneSegmentationSwitch", + true); + anAction->setToggleAction(true); + anAction->setStatusTip(tr("DSC_VVTK_PLANE_SEGMENTATION_SWITCH")); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(OnPlaneSegmentationSwitch(bool))); + anAction->addTo( myPtsToolBar ); +} + +void +VVTK_MainWindow1 +::Initialize() +{ + myRenderer = VVTK_Renderer1::New(); + VVTK_MainWindowBase::Initialize(myRenderer.GetPointer()); + myRenderer->Delete(); +} + +VVTK_MainWindow1 +::~VVTK_MainWindow1() +{} + + +//---------------------------------------------------------------------------- +VVTK_Renderer1* +VVTK_MainWindow1 +::GetRenderer1() +{ + return myRenderer.GetPointer(); +} + //---------------------------------------------------------------------------- QSize -VVTK_MainWindow +VVTK_MainWindow1 ::sizeHint() const { QWidget* aParent = parentWidget(); @@ -113,66 +177,44 @@ VVTK_MainWindow return QSize(aWidth,aHeight); } - //---------------------------------------------------------------------------- void -VVTK_MainWindow -::onInteractorStyleSwitch(bool theIsVVTKStyle) +VVTK_MainWindow1 +::OnPlaneSegmentationSwitch(bool theIsPlaneSegmentationOn) { - // default interactor style which is pushed in this view window constructor - // is VVTK. If it is a current interactor style -- push SVTK "above" it. - // if SVTK is a current one - pop it (remove from stack), below it there MUST BE - // (logically) a VVTK interactor style. - if ( theIsVVTKStyle ) - this->PopInteractorStyle(); - else - this->PushInteractorStyle(myInteractorStyle.GetPointer()); + myRenderer->GetImplicitPlaneWidget()->SetEnabled(theIsPlaneSegmentationOn); } -//---------------------------------------------------------------------------- -void -VVTK_MainWindow -::onSelectionModeSwitch(bool theIsSelectionOn) -{ - SetSelectionMode(theIsSelectionOn? NodeSelection: ActorSelection); -} //---------------------------------------------------------------------------- -VVTK_SMainWindow -::VVTK_SMainWindow(QWidget* theParent, +VVTK_MainWindow2 +::VVTK_MainWindow2(QWidget* theParent, const char* theName, - SUIT_ResourceMgr* theResourceMgr): - VVTK_MainWindow(theParent,theName,theResourceMgr) + SUIT_ResourceMgr* theResourceMgr, + VVTK_MainWindow1* theMainWindow): + VVTK_MainWindowBase(theParent,theName,theResourceMgr), + myMainWindow(theMainWindow) {} void -VVTK_SMainWindow +VVTK_MainWindow2 ::Initialize() { - SetInteractor(new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor")); - - SVTK_Renderer* aRenderer = SVTK_Renderer::New(); - GetInteractor()->SetRenderer(aRenderer); - aRenderer->Delete(); + myRenderer = VVTK_Renderer2::New(); + VVTK_MainWindowBase::Initialize(myRenderer.GetPointer()); + myRenderer->Delete(); - SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New(); - GetInteractor()->PushInteractorStyle(aStyle); - aStyle->Delete(); - - // important! : the default interactor style which is pushed is VVTK - // see onInteractorStyleSwitch() for details - PushInteractorStyle(myInteractorStyle.GetPointer()); + myRenderer->SetRenderer1(myMainWindow->GetRenderer1()); } -VVTK_SMainWindow -::~VVTK_SMainWindow() +VVTK_MainWindow2 +::~VVTK_MainWindow2() {} - //---------------------------------------------------------------------------- QSize -VVTK_SMainWindow +VVTK_MainWindow2 ::sizeHint() const { QWidget* aParent = parentWidget(); diff --git a/src/VVTK/VVTK_View.h b/src/VVTK/VVTK_View.h index 66206770..af8544ea 100644 --- a/src/VVTK/VVTK_View.h +++ b/src/VVTK/VVTK_View.h @@ -8,57 +8,91 @@ #include "VVTK.h" #include "SVTK_View.h" +class VVTK_Renderer1; +class VVTK_Renderer2; //---------------------------------------------------------------------------- -class VVTK_EXPORT VVTK_MainWindow: public SVTK_MainWindow +class VVTK_EXPORT VVTK_MainWindowBase: public SVTK_MainWindow { Q_OBJECT; public: - VVTK_MainWindow(QWidget* theParent, - const char* theName, - SUIT_ResourceMgr* theResourceMgr); + VVTK_MainWindowBase(QWidget* theParent, + const char* theName, + SUIT_ResourceMgr* theResourceMgr); + virtual + void + Initialize(SVTK_Renderer *theRenderer); + + virtual + ~VVTK_MainWindowBase(); + + public slots: + void OnInteractorStyleSwitch(bool theIsGaussStyleOn); + void OnSelectionModeSwitch(bool theIsSelectionOn); + + protected: + QToolBar* myPtsToolBar; + vtkSmartPointer myInteractorStyle; +}; + + +//---------------------------------------------------------------------------- +class VVTK_EXPORT VVTK_MainWindow1: public VVTK_MainWindowBase +{ + Q_OBJECT; + +public: + VVTK_MainWindow1(QWidget* theParent, + const char* theName, + SUIT_ResourceMgr* theResourceMgr); virtual void Initialize(); virtual - ~VVTK_MainWindow(); + ~VVTK_MainWindow1(); + + VVTK_Renderer1* + GetRenderer1(); virtual QSize sizeHint() const; public slots: - void onInteractorStyleSwitch(bool theIsVVTKStyle); - void onSelectionModeSwitch(bool theIsSelectionOn); + void OnPlaneSegmentationSwitch(bool theIsPlaneSegmentationOn); protected: - QToolBar* myPtsToolBar; - vtkSmartPointer myInteractorStyle; + vtkSmartPointer myRenderer; }; //---------------------------------------------------------------------------- -class VVTK_EXPORT VVTK_SMainWindow: public VVTK_MainWindow +class VVTK_EXPORT VVTK_MainWindow2: public VVTK_MainWindowBase { Q_OBJECT; public: - VVTK_SMainWindow(QWidget* theParent, - const char* theName, - SUIT_ResourceMgr* theResourceMgr); + VVTK_MainWindow2(QWidget* theParent, + const char* theName, + SUIT_ResourceMgr* theResourceMgr, + VVTK_MainWindow1* theMainWindow); virtual void Initialize(); virtual - ~VVTK_SMainWindow(); + ~VVTK_MainWindow2(); virtual QSize sizeHint() const; + + protected: + VVTK_MainWindow1* myMainWindow; + vtkSmartPointer myRenderer; }; diff --git a/src/VVTK/VVTK_ViewWindow.cxx b/src/VVTK/VVTK_ViewWindow.cxx index c2f457bb..b443a75c 100755 --- a/src/VVTK/VVTK_ViewWindow.cxx +++ b/src/VVTK/VVTK_ViewWindow.cxx @@ -1,7 +1,37 @@ +// SALOME VTKViewer : build VTK viewer into Salome desktop +// +// 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 +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : +// Author : +// Module : SALOME +// $Header$ + #include "VVTK_ViewWindow.h" #include "VVTK_ViewModel.h" #include "VVTK_View.h" +#include "VISU_GaussPtsAct.h" + #include "SUIT_Session.h" #include @@ -10,7 +40,10 @@ //---------------------------------------------------------------------------- VVTK_ViewWindow ::VVTK_ViewWindow(SUIT_Desktop* theDesktop): - SVTK_ViewWindow(theDesktop) + SVTK_ViewWindow(theDesktop), + myMainWindow1(NULL), + myMainWindow2(NULL), + myView2(NULL) {} //---------------------------------------------------------------------------- @@ -26,20 +59,22 @@ VVTK_ViewWindow aLayout->setAutoAdd(true); QSplitter* aSplitter = new QSplitter(Qt::Vertical,aWidget); - myMainWindow = new VVTK_MainWindow(aSplitter, - "VVTK_MainWindow", - aResourceMgr); + myMainWindow1 = new VVTK_MainWindow1(aSplitter, + "VVTK_MainWindow", + aResourceMgr); + myMainWindow = myMainWindow1; myMainWindow->Initialize(); - + myView = new SVTK_View(myMainWindow); SVTK_ViewWindow::Initialize(myView,theModel); - mySMainWindow = new VVTK_SMainWindow(aSplitter, - "VVTK_SegmantationWindow", - aResourceMgr); - mySMainWindow->Initialize(); + myMainWindow2 = new VVTK_MainWindow2(aSplitter, + "VVTK_SegmantationWindow", + aResourceMgr, + myMainWindow1); + myMainWindow2->Initialize(); - mySView = new SVTK_View(mySMainWindow); + myView2 = new SVTK_View(myMainWindow2); } } @@ -47,3 +82,45 @@ VVTK_ViewWindow VVTK_ViewWindow ::~VVTK_ViewWindow() {} + + +//---------------------------------------------------------------------------- +void +VVTK_ViewWindow +::AddActor(VTKViewer_Actor* theActor, + bool theIsUpdate) +{ + SVTK_ViewWindow::AddActor(theActor,theIsUpdate); + if(VISU_Actor* anAct = dynamic_cast(theActor)) + if(VISU::TActorFactory* aFactory = anAct->GetFactory()) + if(VISU_Actor* anActor = aFactory->CreateActor()) + myMainWindow2->AddActor(anActor,theIsUpdate); +} + +//---------------------------------------------------------------------------- +void +VVTK_ViewWindow +::RemoveActor(VTKViewer_Actor* theActor, + bool theIsUpdate) +{ + SVTK_ViewWindow::RemoveActor(theActor,theIsUpdate); + myMainWindow2->RemoveActor(theActor,theIsUpdate); +} + +//---------------------------------------------------------------------------- +void +VVTK_ViewWindow +::onResetView() +{ + myMainWindow1->onResetView(); + myMainWindow2->onResetView(); +} + +//---------------------------------------------------------------------------- +void +VVTK_ViewWindow +::onFitAll() +{ + myMainWindow1->onFitAll(); + myMainWindow2->onFitAll(); +} diff --git a/src/VVTK/VVTK_ViewWindow.h b/src/VVTK/VVTK_ViewWindow.h index edb1fba6..0aacd4c9 100755 --- a/src/VVTK/VVTK_ViewWindow.h +++ b/src/VVTK/VVTK_ViewWindow.h @@ -8,8 +8,8 @@ #include "VVTK.h" #include "SVTK_ViewWindow.h" -class VVTK_SMainWindow; -class VVTK_MainWindow; +class VVTK_MainWindow1; +class VVTK_MainWindow2; class SVTK_View; class VVTK_EXPORT VVTK_ViewWindow : public SVTK_ViewWindow @@ -22,13 +22,33 @@ public: virtual ~VVTK_ViewWindow(); + virtual + void + AddActor(VTKViewer_Actor* theActor, + bool theIsUpdate = false); + + virtual + void + RemoveActor(VTKViewer_Actor* theActor, + bool theIsUpdate = false); + virtual void Initialize(SVTK_ViewModelBase* theModel); +public slots: + virtual + void + onResetView(); + + virtual + void + onFitAll(); + protected: - VVTK_SMainWindow* mySMainWindow; - SVTK_View* mySView; + VVTK_MainWindow1* myMainWindow1; + VVTK_MainWindow2* myMainWindow2; + SVTK_View* myView2; }; #ifdef WIN32 -- 2.39.2