From 956ff5b55807d6bcca3dd4822ed7bb13ff901d7a Mon Sep 17 00:00:00 2001 From: mkr Date: Wed, 22 Jun 2005 09:48:45 +0000 Subject: [PATCH] Fix for bug IPAL9214 : 3.0.0(/dn06/../current1506): dataflow object has no "Rename", "Display", "Delete" popup functionalities. --- src/SUPERVGUI/Makefile.in | 1 + src/SUPERVGUI/SUPERVGUI.cxx | 64 ++++++++++++------ src/SUPERVGUI/SUPERVGUI.h | 3 +- src/SUPERVGUI/SUPERVGUI_Selection.cxx | 94 +++++++++++++++++++++++++++ src/SUPERVGUI/SUPERVGUI_Selection.h | 56 ++++++++++++++++ src/SUPERVGUI/SUPERV_msg_en.po | 27 ++++++++ 6 files changed, 225 insertions(+), 20 deletions(-) create mode 100644 src/SUPERVGUI/SUPERVGUI_Selection.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_Selection.h diff --git a/src/SUPERVGUI/Makefile.in b/src/SUPERVGUI/Makefile.in index d8a5415..0655a87 100644 --- a/src/SUPERVGUI/Makefile.in +++ b/src/SUPERVGUI/Makefile.in @@ -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 \ diff --git a/src/SUPERVGUI/SUPERVGUI.cxx b/src/SUPERVGUI/SUPERVGUI.cxx index e97ccda..b685097 100644 --- a/src/SUPERVGUI/SUPERVGUI.cxx +++ b/src/SUPERVGUI/SUPERVGUI.cxx @@ -28,6 +28,7 @@ using namespace std; #include "SUPERVGUI.h" #include "SUPERVGUI_DataModel.h" +#include "SUPERVGUI_Selection.h" #include "SALOMEDSClient.hxx" #include @@ -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(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); diff --git a/src/SUPERVGUI/SUPERVGUI.h b/src/SUPERVGUI/SUPERVGUI.h index f5bd8d9..0c9649d 100644 --- a/src/SUPERVGUI/SUPERVGUI.h +++ b/src/SUPERVGUI/SUPERVGUI.h @@ -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 index 0000000..f361615 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Selection.cxx @@ -0,0 +1,94 @@ +#include "SUPERVGUI_Selection.h" +#include "SUPERVGUI.h" + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include + +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 + (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 + (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 index 0000000..6c7c2f3 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Selection.h @@ -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 + +#include + +#include "SALOMEDSClient.hxx" +#include +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 diff --git a/src/SUPERVGUI/SUPERV_msg_en.po b/src/SUPERVGUI/SUPERV_msg_en.po index 19bb638..1711f49 100644 --- a/src/SUPERVGUI/SUPERV_msg_en.po +++ b/src/SUPERVGUI/SUPERV_msg_en.po @@ -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" -- 2.39.2