]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Selector implementation for OCC viewer.
authoradv <adv@opencascade.com>
Fri, 27 Sep 2013 13:10:15 +0000 (13:10 +0000)
committeradv <adv@opencascade.com>
Fri, 27 Sep 2013 13:10:15 +0000 (13:10 +0000)
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI.vcproj
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_OCCSelector.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_OCCSelector.h [new file with mode: 0644]

index 380ea7922a558f75f693eff9a01693da49c29f67..a92c80f11ff31c77d8ab5f623d0675731953575b 100644 (file)
@@ -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
index fc8098393045bd25dfa22f7967491dbc7225b514..c5cbe2e53aff1b93fd57db246e60a469520a67eb 100644 (file)
@@ -51,7 +51,7 @@
                                AdditionalOptions="/MP"
                                Optimization="0"
                                AdditionalIncludeDirectories=".;../HYDROData;&quot;$(SUITINC)&quot;;&quot;$(GEOMINC)&quot;;&quot;$(OCCINC)&quot;;$(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"
                                RelativePath=".\HYDROGUI_OCCDisplayer.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROGUI_OCCSelector.cxx"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROGUI_Operation.cxx"
                                >
                                RelativePath=".\HYDROGUI_OCCDisplayer.h"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROGUI_OCCSelector.h"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generating moc_$(InputName).cxx"
+                                               CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx"
+                                               Outputs="moc/moc_$(InputName).cxx"
+                                       />
+                               </FileConfiguration>
+                       </File>
                        <File
                                RelativePath=".\HYDROGUI_Operation.h"
                                >
                                RelativePath=".\moc\moc_HYDROGUI_ObserveImageOp.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath=".\moc\moc_HYDROGUI_OCCSelector.cxx"
+                               >
+                       </File>
                        <File
                                RelativePath=".\moc\moc_HYDROGUI_Operation.cxx"
                                >
index 4c2a2cc5e2202f8120d62a027cc4b18585a1c240..81b8786fc6548957daa68f0c41071100911872fe 100644 (file)
@@ -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<GraphicsView_ViewManager*>( theViewManager );
-  if( !aViewManager )
+  if( aViewType != GraphicsView_Viewer::Type() &&
+      aViewType != OCCViewer_Viewer::Type())
     return;
 
   QList<SUIT_Selector*> 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<HYDROGUI_GVSelector*>( aSelector ) )
+    if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
+                       !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
       aSelector->setEnabled( false );
   }
 
-  new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
+  if ( aViewType == GraphicsView_Viewer::Type() )
+  {
+    GraphicsView_ViewManager* aViewManager =
+      ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
+    if( aViewManager )
+      new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
+  }
+  else if ( aViewType == OCCViewer_Viewer::Type() )
+  {
+    OCCViewer_ViewManager* aViewManager =
+      ::qobject_cast<OCCViewer_ViewManager*>( 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 (file)
index 0000000..24d8975
--- /dev/null
@@ -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 <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+
+#include <LightApp_DataOwner.h>
+
+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 (file)
index 0000000..b427fd3
--- /dev/null
@@ -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 <LightApp_OCCSelector.h>
+
+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