]> SALOME platform Git repositories - modules/superv.git/commitdiff
Salome HOME
Fix for PAL8150 : CRASH after "Put in Study" applied to the "readMeshInFile" node.
authormkr <mkr@opencascade.com>
Fri, 17 Feb 2006 15:01:07 +0000 (15:01 +0000)
committermkr <mkr@opencascade.com>
Fri, 17 Feb 2006 15:01:07 +0000 (15:01 +0000)
src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx
src/SUPERVGUI/SUPERVGUI_CanvasPort.h
src/SUPERVGUI/SUPERVGUI_Main.cxx
src/SUPERVGUI/SUPERVGUI_Main.h

index 2b8b0f51add8e481827c7cc3b0601cd3c4e080d5..b6900925b87f190df569fd218434cba8172a5791 100644 (file)
@@ -259,6 +259,9 @@ SUPERVGUI_CanvasPortOut::SUPERVGUI_CanvasPortOut(QObject* theParent, SUPERVGUI_M
 {
   Trace("SUPERVGUI_CanvasPortOut::SUPERVGUI_CanvasPortOut");
   myInStudy = false;
+
+  // mkr : PAL8150
+  connect(this, SIGNAL(putInStudy( QString* )), getMain(), SLOT(onPutInStudy( QString* )));
 }
 
 SUPERVGUI_CanvasPortOut::~SUPERVGUI_CanvasPortOut()
@@ -321,6 +324,11 @@ void SUPERVGUI_CanvasPortOut::toStudy()
       aSupMod->unregisterGraph(getMain());
       aSupMod->registerGraph(getMain()->getDataflow()->getIOR(), getMain());
     }
+  
+  // mkr : PAL8150
+  QString aNodePortName = QString( getEngine()->Node()->Name() ) + QString( "_" ) + QString( getEngine()->Name() );
+  emit putInStudy( &aNodePortName );
+
 }
 
 
index 6ed5f5dc0af3a246654e4f914fe0b4a83453858c..e218d572709079bd0add3ac6ad44ef08ab0c5cc1 100644 (file)
@@ -97,6 +97,9 @@ class SUPERVGUI_CanvasPortOut : public SUPERVGUI_CanvasPort {
 
     virtual QPopupMenu* getPopupMenu(QWidget* theParent);
 
+  signals:
+    void putInStudy( QString* ); // mkr : PAL8150
+
   public slots:
     void toStudy();
 
index 8b5ceba1aa73ebeb5d464335a9c75d996e4181d4..4aa33b01556855105545704aaf75a233dc91fe29 100644 (file)
 #include <boost/shared_ptr.hpp>
 using namespace boost;
 
+// mkr : PAL8150
+#define SYNCPUTINSTUDY(NodesName)  \
+    for ( int n = 0; n < nodes->NodesName.length(); n++ ) { \
+      SUPERV_CNode aCNode = SUPERV::CNode::_narrow(nodes->NodesName[n]); \
+      SUPERV_Ports aPortList = aCNode->Ports(); \
+      for (int p = 0; p < aPortList->length(); p++) { \
+        SUPERV::Port_ptr aPort = aPortList[p].in(); \
+        if ( !aPort->IsInput() && !aPort->IsGate() ) { \
+          bool aInStudy = dynamic_cast<SUPERVGUI_CanvasPortOut*>( aMain->getCanvas()->getPort(aPort) )->isInStudy(); \
+          dynamic_cast<SUPERVGUI_CanvasPortOut*>( getCanvas()->getPort( getDataflow()->Node(aCNode->Name())->Port(aPort->Name()) ) )->setStudyState(aInStudy); \
+        } \
+      } \
+    }
+
 SUPERVGUI_Main::SUPERVGUI_Main( SUPERVGraph_ViewFrame* theParent, 
                                SUIT_Desktop* theDesktop, SUPERV_Graph theDataFlow )
      : SUPERVGraph_View(theParent),
@@ -88,6 +102,9 @@ SUPERVGUI_Main::SUPERVGUI_Main( SUPERVGraph_ViewFrame* theParent,
   } else {
     init(theDesktop);
   }
+
+  syncPutInStudy(); // mkr : PAL8150
+
   // mkr : IPAL11362
   connect(this, SIGNAL(EventToSync()), this, SLOT(onObjectCreatedDeleted()));
 }
@@ -605,6 +622,84 @@ void SUPERVGUI_Main::onObjectCreatedDeleted()
   }
 }
 
+// mkr : PAL8150 : synchronize many views of the same dataflow ("Put In Study"/"Not In Study" operation)
+void SUPERVGUI_Main::onPutInStudy( QString* theNodePortName )
+{
+  if ( study ) {
+    if ( STD_Application* app = dynamic_cast<STD_Application*>( study->application() ) ) {
+      ViewManagerList aVMList;
+      app->viewManagers( SUPERVGraph_Viewer::Type(), aVMList );
+      SUIT_ViewManager* aVM;
+      for ( aVM = aVMList.first(); aVM; aVM = aVMList.next() ) {
+       QPtrVector<SUIT_ViewWindow> aVWList = aVM->getViews();
+       for ( int i = 0; i < aVWList.count(); i++ ) {
+         SUPERVGraph_ViewFrame* aVW = dynamic_cast<SUPERVGraph_ViewFrame*>( aVWList[i] );
+         QObjectList* aMainList = aVW->queryList("SUPERVGUI_Main");
+         if ( aMainList->count() == 1 ) {
+           SUPERVGUI_Main* aMain = dynamic_cast<SUPERVGUI_Main*>( aMainList->first() );
+           if ( aMain )
+             if ( !QString(aMain->getDataflow()->getIOR()).compare(getDataflow()->getIOR()) // equal dataflows
+                  && 
+                  aMain != this ) { // not equal mains
+               QString aNodeName = theNodePortName->left( theNodePortName->find('_') );
+               QString aPortName = theNodePortName->right( theNodePortName->length() - theNodePortName->find('_') - 1 );
+               bool anIsInStudy = dynamic_cast<SUPERVGUI_CanvasPortOut*>( getCanvas()->getPort( getDataflow()->Node( aNodeName )->GetOutPort( aPortName ) ) )->isInStudy();
+               dynamic_cast<SUPERVGUI_CanvasPortOut*>( aMain->getCanvas()->getPort( aMain->getDataflow()->Node( aNodeName )->GetOutPort( aPortName ) ) )->setStudyState( anIsInStudy );
+             }
+         }
+       }
+      }
+    }
+  }
+}
+
+// mkr : PAL8150 : synchronize many views of the same dataflow ("Display" operation for dataflow)
+void SUPERVGUI_Main::syncPutInStudy()
+{
+  if ( study ) {
+    if ( STD_Application* app = dynamic_cast<STD_Application*>( study->application() ) ) {
+      ViewManagerList aVMList;
+      app->viewManagers( SUPERVGraph_Viewer::Type(), aVMList );
+      SUIT_ViewManager* aVM;
+      for ( aVM = aVMList.first(); aVM; aVM = aVMList.next() ) {
+       QPtrVector<SUIT_ViewWindow> aVWList = aVM->getViews();
+       for ( int i = 0; i < aVWList.count(); i++ ) {
+         SUPERVGraph_ViewFrame* aVW = dynamic_cast<SUPERVGraph_ViewFrame*>( aVWList[i] );
+         QObjectList* aMainList = aVW->queryList("SUPERVGUI_Main");
+         if ( aMainList->count() == 1 ) {
+           SUPERVGUI_Main* aMain = dynamic_cast<SUPERVGUI_Main*>( aMainList->first() );
+           if ( aMain )
+             if ( !CORBA::is_nil( aMain->getDataflow() )
+                  &&
+                  !QString(aMain->getDataflow()->getIOR()).compare(getDataflow()->getIOR()) // equal dataflows
+                  && 
+                  aMain != this ) { // not equal mains
+       
+               // check "myInStudy" field of output ports of original main (i.e. this main)
+               // and synchronize this property for nodes' output ports of dublicate main (i.e. of aMain)
+               SUPERV_Nodes nodes = aMain->getDataflow()->Nodes();
+               
+               SYNCPUTINSTUDY(CNodes);
+               SYNCPUTINSTUDY(FNodes);
+               SYNCPUTINSTUDY(INodes);
+               SYNCPUTINSTUDY(GNodes);
+               SYNCPUTINSTUDY(LNodes);
+               SYNCPUTINSTUDY(ELNodes);
+               SYNCPUTINSTUDY(SNodes);
+               SYNCPUTINSTUDY(ESNodes);
+               SYNCPUTINSTUDY(Graphs);
+
+               setRunTime( aMain->getRunTime() );
+
+               break;
+             }
+         }
+       }
+      }
+    }
+  }
+}
+
 void SUPERVGUI_Main::run( const bool andSuspend ) {
   Trace("SUPERVGUI_Main::run");
   if ( SUPERV_isNull(dataflow) ) 
index cd5496a9ac8bba5bf7647a889fd88b8eebd97a35..a6a6ac83b10ca478e9de9a53a3b968d33fa59240 100644 (file)
@@ -136,6 +136,10 @@ class SUPERVGUI_Main: public SUPERVGraph_View {
 
     virtual void resizeView( QResizeEvent* theEvent );
 
+    // mkr : PAL8150
+    void setRunTime( QDateTime theRunTime ) { myRunTime = theRunTime; }
+    QDateTime getRunTime() const { return myRunTime; }
+
   signals:
     void KillMyThread(bool theValue);
     void EventToSync(); // mkr : IPAL11362
@@ -162,6 +166,7 @@ class SUPERVGUI_Main: public SUPERVGraph_View {
     void onShowToolbar();
 
     void onObjectCreatedDeleted(); // mkr : PAL8237
+    void onPutInStudy( QString* ); // mkr : PAL8150
  
   private slots:
     void chooseData(QListViewItem* item);
@@ -172,7 +177,8 @@ class SUPERVGUI_Main: public SUPERVGraph_View {
     void syncNotification();
     bool isFiltered(char* graph, char* node, char* type, char* message, char* sender, long counter, char* date, long stamp);
     void closeEvent(QCloseEvent*);
-
+    void syncPutInStudy(); // mkr : PAL8150
+    
     SUPERV_Graph            dataflow;
 
     QMap<QString, SUIT_ViewWindow*> mySubGraphs;