Salome HOME
Fix for bug IPAL9214 : 3.0.0(/dn06/../current1506): dataflow object has no "Rename...
authormkr <mkr@opencascade.com>
Wed, 22 Jun 2005 09:48:45 +0000 (09:48 +0000)
committermkr <mkr@opencascade.com>
Wed, 22 Jun 2005 09:48:45 +0000 (09:48 +0000)
src/SUPERVGUI/Makefile.in
src/SUPERVGUI/SUPERVGUI.cxx
src/SUPERVGUI/SUPERVGUI.h
src/SUPERVGUI/SUPERVGUI_Selection.cxx [new file with mode: 0644]
src/SUPERVGUI/SUPERVGUI_Selection.h [new file with mode: 0644]
src/SUPERVGUI/SUPERV_msg_en.po

index d8a54150040a3917a7c207e2b4f79cf9c3ddb768..0655a8779f8bb55ea4d9780c98fcc796ecdcc0a4 100644 (file)
@@ -49,6 +49,7 @@ LIB = libSUPERV.la
 
 LIB_SRC = SUPERVGUI.cxx                      \
          SUPERVGUI_DataModel.cxx            \
+         SUPERVGUI_Selection.cxx            \
          SUPERVGUI_ArrayView.cxx            \
           SUPERVGUI_Canvas.cxx               \
          SUPERVGUI_CanvasArray.cxx          \
index e97ccda262558a256b50a38be9aafcaf1adab194..b6850979deec96a3635bf2cf21141852fa83998e 100644 (file)
@@ -28,6 +28,7 @@
 using namespace std;
 #include "SUPERVGUI.h"
 #include "SUPERVGUI_DataModel.h"
+#include "SUPERVGUI_Selection.h"
 
 #include "SALOMEDSClient.hxx"
 #include <boost/shared_ptr.hpp>
@@ -157,6 +158,10 @@ void SUPERVGUI::initialize( CAM_Application* app )
   createSupervAction( 309, "ADDNODE" );
   createSupervAction( 310, "STEPBYSTEP" );
 
+  createSupervAction( 311, "POP_RENAME" );
+  createSupervAction( 312, "POP_DISPLAY" );
+  createSupervAction( 313, "POP_DELETE" );
+
   // ----- create menu -----------------
   int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
   createMenu( 301, fileId, 10 );
@@ -192,6 +197,15 @@ void SUPERVGUI::initialize( CAM_Application* app )
   createTool( 307, executionId );
   createTool( 308, executionId );
 
+  // ----- create popup for object browser items -------------
+  QtxPopupMgr* mgr = popupMgr();
+  mgr->insert( action(  311 ), -1, -1 ); // rename dataflow
+  mgr->setRule( action( 311 ), "$type in {'Dataflow'} and selcount=1", true );
+  mgr->insert( action(  312 ), -1, -1 ); // display dataflow
+  mgr->setRule( action( 312 ), "$type in {'Dataflow'} and selcount=1", true );
+  mgr->insert( separator(), -1, -1 ); // -----------
+  mgr->insert( action(  313 ), -1, -1 ); // delete object
+  mgr->setRule( action( 313 ), "$client in {'ObjectBrowser'} and $type in {'Dataflow' 'SupervisorObject'} and selcount>0", true );
 }
 
 bool SUPERVGUI::activateModule( SUIT_Study* theStudy )
@@ -240,6 +254,11 @@ CAM_DataModel* SUPERVGUI::createDataModel()
   return new SUPERVGUI_DataModel( this );
 }
 
+SalomeApp_Selection* SUPERVGUI::createSelection() const
+{
+  return new SUPERVGUI_Selection();
+}
+
 SUIT_ViewWindow* SUPERVGUI::createGraph() {
   SUPERVGraph_ViewManager* aVM = new SUPERVGraph_ViewManager( study, application()->desktop(), new SUPERVGraph_Viewer() );
   SUIT_ViewWindow* aVW = aVM->createViewWindow();
@@ -384,10 +403,8 @@ void SUPERVGUI::setMain( SUIT_ViewWindow* w) {
   if ( !w ) return;
 
   study = w->getViewManager()->study();
-  if (!study) {
-    cout<<" setMain(...) : NULL study!";
+  if (!study)
     return;
-  }
 
   if(SUPERVGraph_ViewFrame* supervFrame = dynamic_cast<SUPERVGraph_ViewFrame*>(w)){
     SUPERVGraph_View* view = supervFrame->getViewWidget();
@@ -730,28 +747,23 @@ void SUPERVGUI::showComponents() {
  
 
 /** Returns:
-    theIsOwner = true if Selected object belongs to Suipervision.
+    theIsOwner = true if Selected object belongs to Supervision.
     theIsDataflow = true if Selected object is Dataflow
 */
-void SUPERVGUI::whatIsSelected(const Handle(SALOME_InteractiveObject)& theObj, bool& theIsOwner, bool& theIsDataflow) {
+void SUPERVGUI::whatIsSelected(const _PTR(SObject)& theObj, bool& theIsOwner, bool& theIsDataflow) {
   theIsOwner = false;
   theIsDataflow = false;
 
-  if (theObj.IsNull()) return;
-  
-  _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
-  _PTR(SObject) obj ( aStudy->FindObjectID( theObj->getEntry() ) );
-
-  if ( obj ) {
-    _PTR(SComponent) comp ( obj->GetFatherComponent() );
+  if ( theObj ) {
+    _PTR(SComponent) comp ( theObj->GetFatherComponent() );
     if ( comp ) {
       _PTR(GenericAttribute) anAttr;
       if (comp->FindAttribute(anAttr, "AttributeName")) {
        _PTR(AttributeName) aName ( anAttr );
        QString compName(aName->Value().c_str());
-       if ( compName.compare( (( CAM_Application* )application())->moduleTitle( moduleName() ) ) == 0 ) {
+       if ( compName.compare( moduleName() ) == 0 ) {
          _PTR(GenericAttribute) anAttr;
-         if (obj->FindAttribute(anAttr, "AttributeIOR")) {
+         if (theObj->FindAttribute(anAttr, "AttributeIOR")) {
            _PTR(AttributeIOR) anIOR ( anAttr );
            SUPERV_Graph aDataFlow = engine->getGraph(anIOR->Value().c_str());
            if (!SUPERV_isNull(aDataFlow)) {
@@ -763,9 +775,10 @@ void SUPERVGUI::whatIsSelected(const Handle(SALOME_InteractiveObject)& theObj, b
                theIsDataflow = true;
            }
          }
-         CORBA::String_var anObjectID = obj->GetID().c_str();
+         CORBA::String_var anObjectID = theObj->GetID().c_str();
          CORBA::String_var aComponentID = comp->GetID().c_str();
-         if (strcmp(anObjectID, aComponentID)) theIsOwner = true;          
+         if (strcmp(anObjectID, aComponentID))
+           theIsOwner = true;      
        }
       }
     }
@@ -796,8 +809,8 @@ void SUPERVGUI::deleteObject() {
   SALOME_ListIteratorOfListIO It( aList );
   for(;It.More();It.Next()) {
     Handle(SALOME_InteractiveObject) anIObj = It.Value();
-    bool aIsOwner, aIsDataflow;
-    whatIsSelected(anIObj, aIsOwner, aIsDataflow);
+    //bool aIsOwner, aIsDataflow;
+    //whatIsSelected(anIObj, aIsOwner, aIsDataflow);
     
     _PTR(SObject) aObj ( aStudy->FindObjectID( anIObj->getEntry() ) );
     if ( aObj ) {
@@ -809,6 +822,7 @@ void SUPERVGUI::deleteObject() {
     }
   }
   (( SalomeApp_Application* )application())->selectionMgr()->clearSelected();
+  updateObjBrowser();
 }
 
 void SUPERVGUI::OnGUIEvent()
@@ -862,7 +876,19 @@ bool SUPERVGUI::OnGUIEvent(int command) {
   case 310: 
     stepByStep();
     return(false);
-    
+
+  case 311:
+    renameDataflow();
+    return(false);
+
+  case 312:
+    displayDataflow();
+    return(false);
+
+  case 313:
+    deleteObject();
+    return(false);
+
   default: 
     QMessageBox::warning(application()->desktop(), "Supervision Error", "Unknown Command From Salome");
     return(false);
index f5bd8d9597b614b2e959e3f2b7327450b6c6f2da..0c9649d3d908c61350e6b2bf338b695d9cfca910 100644 (file)
@@ -96,7 +96,7 @@ class SUPERVGUI: public SalomeApp_Module {
        theIsOwner = true if Selected object belongs to Suipervision.
        theIsDataflow = true if Selected object is Dataflow
     */
-    void whatIsSelected(const Handle(SALOME_InteractiveObject)& theObj, bool& theIsOwner, bool& theIsDataflow);
+    void whatIsSelected(const _PTR(SObject)& theObj, bool& theIsOwner, bool& theIsDataflow);
 
     /* asv : bug [VSR Bugs and Improvements in Supervisor] 1.8 : when exporting a file, 
        a backup copy of an existing file must be created (in case Export fails..)
@@ -127,6 +127,7 @@ class SUPERVGUI: public SalomeApp_Module {
       
   protected:
     virtual CAM_DataModel* createDataModel();
+    virtual SalomeApp_Selection* createSelection() const;
 
   private:
     void loadEngine(SALOME_NamingService* namingService);
diff --git a/src/SUPERVGUI/SUPERVGUI_Selection.cxx b/src/SUPERVGUI/SUPERVGUI_Selection.cxx
new file mode 100644 (file)
index 0000000..f361615
--- /dev/null
@@ -0,0 +1,94 @@
+#include "SUPERVGUI_Selection.h"
+#include "SUPERVGUI.h"
+
+#include <SalomeApp_DataOwner.h>
+#include <SalomeApp_Study.h>
+
+#include <SUIT_Session.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_ViewManager.h>
+#include <SUIT_ViewModel.h>
+
+#include <SALOMEDSClient_SObject.hxx>
+#include <SALOMEDSClient_Study.hxx>
+#include <SALOMEDS_SObject.hxx>
+#include <SALOME_Prs.h>
+#include <SALOME_InteractiveObject.hxx>
+
+#include <SOCC_Prs.h>
+
+#include <OCCViewer_ViewModel.h>
+
+SUPERVGUI_Selection::SUPERVGUI_Selection()
+{
+}
+
+SUPERVGUI_Selection::~SUPERVGUI_Selection()
+{
+}
+
+QtxValue SUPERVGUI_Selection::param( const int ind, const QString& p ) const
+{
+  QtxValue val( SalomeApp_Selection::param( ind, p ) );
+  if ( !val.isValid() ) {
+    if ( p == "type" )  val = QtxValue( typeName( ind ) );
+  }
+
+  //printf( "--> param() : [%s] = %s\n", p.latin1(), val.toString ().latin1() );
+
+  return val;
+}
+
+QString SUPERVGUI_Selection::typeName( const int index ) const
+{
+  if ( isComponent( index ) )
+    return "Component";
+  
+  _PTR(SObject) anIObj = getObject( index );
+  if ( anIObj ) {
+    bool aIsOwner, aIsDataflow;
+    SUPERVGUI::Supervision()->whatIsSelected(anIObj, aIsOwner, aIsDataflow);
+    if ( aIsDataflow ) //selected dataflow object
+      return "Dataflow";
+    if ( aIsOwner ) //selected object belongs to Supervisor
+      return "SupervisorObject";
+  }
+  return "Unknown";
+}
+
+bool SUPERVGUI_Selection::isComponent( const int index ) const
+{
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
+    (SUIT_Session::session()->activeApplication()->activeStudy());
+
+  if ( appStudy && index >= 0 && index < count() )  {
+    _PTR(Study) study = appStudy->studyDS();
+    QString anEntry = entry( index );
+
+    if ( study && !anEntry.isNull() ) { 
+      _PTR(SObject) aSO( study->FindObjectID( anEntry.latin1() ) );
+      if ( aSO && aSO->GetFatherComponent() ) 
+       return aSO->GetFatherComponent()->GetIOR() == aSO->GetIOR();
+    }
+  }
+  return false;
+}
+
+_PTR(SObject) SUPERVGUI_Selection::getObject( const int index ) const
+{
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
+    (SUIT_Session::session()->activeApplication()->activeStudy());
+
+  if ( appStudy && index >= 0 && index < count() )  {
+    _PTR(Study) study = appStudy->studyDS();
+    QString anEntry = entry( index );
+
+    if ( study && !anEntry.isNull() ) { 
+      _PTR(SObject) aSO( study->FindObjectID( anEntry.latin1() ) );
+      return aSO;
+    }
+  }
+  
+  _PTR(SObject) aObj1;
+  return aObj1;
+}
diff --git a/src/SUPERVGUI/SUPERVGUI_Selection.h b/src/SUPERVGUI/SUPERVGUI_Selection.h
new file mode 100644 (file)
index 0000000..6c7c2f3
--- /dev/null
@@ -0,0 +1,56 @@
+//  SUPERV SUPERVGUI : GUI for Supervisor component
+//
+//  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   : SUPERVGUI_Selection.h
+//  Author : Margarita KARPUNINA
+//  Module : SUPERV
+
+#ifndef SUPERVGUI_SELECTION_HeaderFile
+#define SUPERVGUI_SELECTION_HeaderFile
+
+#include <SalomeApp_Selection.h>
+
+#include <SALOMEconfig.h>
+
+#include "SALOMEDSClient.hxx"
+#include <boost/shared_ptr.hpp>
+using namespace boost;
+
+class SALOME_InteractiveObject;
+
+class SUPERVGUI_Selection : public SalomeApp_Selection
+{
+public:
+  SUPERVGUI_Selection();
+  virtual ~SUPERVGUI_Selection();
+
+  virtual QtxValue      param( const int, const QString& ) const;
+
+private:
+  QString               typeName( const int ) const;  
+
+  bool                  isComponent( const int ) const;
+  _PTR(SObject)         getObject( const int ) const;
+};
+
+#endif
index 19bb6389c8ca31aef535e84323e0e32fdd57da85..1711f495423d9ee4beb0466902b18c50dc139d85 100644 (file)
@@ -910,6 +910,33 @@ msgstr "Step by Step"
 msgid "STB_STEPBYSTEP"
 msgstr "Step by Step execution"
 
+msgid "TOP_POP_RENAME"
+msgstr "Rename Dataflow"
+
+msgid "MEN_POP_RENAME"
+msgstr "Rename"
+
+msgid "STB_POP_RENAME"
+msgstr "Rename Dataflow"
+
+msgid "TOP_POP_DISPLAY"
+msgstr "Display Dataflow"
+
+msgid "MEN_POP_DISPLAY"
+msgstr "Display"
+
+msgid "STB_POP_DISPLAY"
+msgstr "Display Dataflow"
+
+msgid "TOP_POP_DELETE"
+msgstr "Delete object(s)"
+
+msgid "MEN_POP_DELETE"
+msgstr "Delete"
+
+msgid "STB_POP_DELETE"
+msgstr "Delete object(s)"
+
 msgid "TOP_KILL"
 msgstr "Kill Running"