From: adv Date: Fri, 27 Sep 2013 13:10:15 +0000 (+0000) Subject: Selector implementation for OCC viewer. X-Git-Tag: BR_hydro_v_0_3~101 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f67a557992493d2ec9508689e3cb8fa3b2227cf1;p=modules%2Fhydro.git Selector implementation for OCC viewer. --- diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 380ea792..a92c80f1 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -23,6 +23,7 @@ set(PROJECT_HEADERS HYDROGUI_ObjSelector.h HYDROGUI_ObserveImageOp.h HYDROGUI_OCCDisplayer.h + HYDROGUI_OCCSelector.h HYDROGUI_Operation.h HYDROGUI_Operations.h HYDROGUI_PolylineDlg.h @@ -72,6 +73,7 @@ set(PROJECT_SOURCES HYDROGUI_ObjSelector.cxx HYDROGUI_ObserveImageOp.cxx HYDROGUI_OCCDisplayer.cxx + HYDROGUI_OCCSelector.cxx HYDROGUI_Operation.cxx HYDROGUI_Operations.cxx HYDROGUI_PolylineDlg.cxx diff --git a/src/HYDROGUI/HYDROGUI.vcproj b/src/HYDROGUI/HYDROGUI.vcproj index fc809839..c5cbe2e5 100644 --- a/src/HYDROGUI/HYDROGUI.vcproj +++ b/src/HYDROGUI/HYDROGUI.vcproj @@ -51,7 +51,7 @@ AdditionalOptions="/MP" Optimization="0" AdditionalIncludeDirectories=".;../HYDROData;"$(SUITINC)";"$(GEOMINC)";"$(OCCINC)";$(QTINC)" - PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_USRDLL;HYDROGUI_EXPORTS;WNT;QT_THREAD_SUPPORT;QT_NO_QT_INCLUDE_WARN;DISABLE_PYCONSOLE;DISABLE_OCCVIEWER;DISABLE_SUPERGRAPHVIEWER" + PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_USRDLL;HYDROGUI_EXPORTS;WNT;QT_THREAD_SUPPORT;QT_NO_QT_INCLUDE_WARN;DISABLE_PYCONSOLE;DISABLE_SUPERGRAPHVIEWER" MinimalRebuild="false" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -206,6 +206,10 @@ RelativePath=".\HYDROGUI_OCCDisplayer.cxx" > + + @@ -567,6 +571,20 @@ RelativePath=".\HYDROGUI_OCCDisplayer.h" > + + + + + @@ -957,6 +975,10 @@ RelativePath=".\moc\moc_HYDROGUI_ObserveImageOp.cxx" > + + diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 4c2a2cc5..81b8786f 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -29,6 +29,7 @@ #include "HYDROGUI_InputPanel.h" #include "HYDROGUI_ObjSelector.h" #include "HYDROGUI_OCCDisplayer.h" +#include "HYDROGUI_OCCSelector.h" #include "HYDROGUI_Operations.h" #include "HYDROGUI_PrsImage.h" #include "HYDROGUI_Tool.h" @@ -666,8 +667,6 @@ void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager ) if( theViewManager->getType() == GraphicsView_Viewer::Type() ) { - createSelector( theViewManager ); // replace the default selector - connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ), this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) ); } @@ -677,6 +676,8 @@ void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager ) this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) ); } + createSelector( theViewManager ); // replace the default selector + ViewManagerInfo anInfo( theViewManager, VMR_General ); myViewManagerMap.insert( ViewManagerId++, anInfo ); } @@ -834,12 +835,8 @@ void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager ) return; QString aViewType = theViewManager->getType(); - if( aViewType != GraphicsView_Viewer::Type() ) - return; - - GraphicsView_ViewManager* aViewManager = - dynamic_cast( theViewManager ); - if( !aViewManager ) + if( aViewType != GraphicsView_Viewer::Type() && + aViewType != OCCViewer_Viewer::Type()) return; QList aSelectorList; @@ -850,11 +847,25 @@ void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager ) for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ ) { SUIT_Selector* aSelector = *anIter; - if( aSelector && !dynamic_cast( aSelector ) ) + if( aSelector && ( !dynamic_cast( aSelector ) && + !dynamic_cast( aSelector ) ) ) aSelector->setEnabled( false ); } - new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr ); + if ( aViewType == GraphicsView_Viewer::Type() ) + { + GraphicsView_ViewManager* aViewManager = + ::qobject_cast( theViewManager ); + if( aViewManager ) + new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr ); + } + else if ( aViewType == OCCViewer_Viewer::Type() ) + { + OCCViewer_ViewManager* aViewManager = + ::qobject_cast( theViewManager ); + if( aViewManager ) + new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr ); + } } bool HYDROGUI_Module::setUpdateEnabled( const bool theState ) diff --git a/src/HYDROGUI/HYDROGUI_OCCSelector.cxx b/src/HYDROGUI/HYDROGUI_OCCSelector.cxx new file mode 100644 index 00000000..24d8975b --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_OCCSelector.cxx @@ -0,0 +1,79 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HYDROGUI_OCCSelector.h" + +#include "HYDROGUI_DataModel.h" +#include "HYDROGUI_DataObject.h" +#include "HYDROGUI_Module.h" + +#include +#include + +#include + +HYDROGUI_OCCSelector::HYDROGUI_OCCSelector( HYDROGUI_Module* theModule, + OCCViewer_Viewer* theViewer, + SUIT_SelectionMgr* theSelMgr ) +: LightApp_OCCSelector( theViewer, theSelMgr ), + myModule( theModule ) +{ +} + +HYDROGUI_OCCSelector::~HYDROGUI_OCCSelector() +{ +} + +void HYDROGUI_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const +{ + OCCViewer_Viewer* aViewer = viewer(); + if ( !aViewer ) + return; + + AIS_ListOfInteractive aSelList; + aViewer->getSelectedObjects( aSelList ); + for ( AIS_ListIteratorOfListOfInteractive anIt( aSelList ); anIt.More(); anIt.Next() ) + if ( !anIt.Value().IsNull() ) + { + aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( entry( anIt.Value() ) ) ) ); + } + // add externally selected objects + SUIT_DataOwnerPtrList::const_iterator anExtIter; + for(anExtIter = mySelectedExternals.begin(); anExtIter != mySelectedExternals.end(); anExtIter++) { + aList.append(*anExtIter); + } +} + +QString HYDROGUI_OCCSelector::entry( const Handle(AIS_InteractiveObject)& anAIS ) const +{ + QString aRes; + + if ( anAIS.IsNull() || !anAIS->HasOwner() ) + return aRes; + + Handle(HYDROData_Object) anObj = + Handle(HYDROData_Object)::DownCast( anAIS->GetOwner() ); + if ( !anObj.IsNull() ) + aRes = HYDROGUI_DataObject::dataObjectEntry( anObj ); + + return aRes; +} \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_OCCSelector.h b/src/HYDROGUI/HYDROGUI_OCCSelector.h new file mode 100644 index 00000000..b427fd34 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_OCCSelector.h @@ -0,0 +1,51 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_OCCSELECTOR_H +#define HYDROGUI_OCCSELECTOR_H + +#include + +class HYDROGUI_Module; +class OCCViewer_Viewer; +class Handle_AIS_InteractiveObject; + +class HYDROGUI_OCCSelector : public LightApp_OCCSelector +{ + Q_OBJECT + +public: + HYDROGUI_OCCSelector( HYDROGUI_Module*, + OCCViewer_Viewer*, + SUIT_SelectionMgr* ); + virtual ~HYDROGUI_OCCSelector(); + +protected: + virtual void getSelection( SUIT_DataOwnerPtrList& ) const; + + virtual QString entry( const Handle_AIS_InteractiveObject& ) const; + +private: + HYDROGUI_Module* myModule; +}; + +#endif