]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Implementation of the first task of the VISU/MULTIPR industrialization project -...
authorapo <apo@opencascade.com>
Wed, 27 Jun 2007 07:48:19 +0000 (07:48 +0000)
committerapo <apo@opencascade.com>
Wed, 27 Jun 2007 07:48:19 +0000 (07:48 +0000)
32 files changed:
idl/VISU_Gen.idl
src/CONVERTOR/VISU_Convertor.cxx
src/CONVERTOR/VISU_Convertor.hxx
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_MedConvertor.cxx
src/CONVERTOR/VISU_MedConvertor.hxx
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_InputPane.cxx
src/VISUGUI/VisuGUI_PopupTools.cxx
src/VISUGUI/VisuGUI_PopupTools.h
src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx
src/VISU_I/Makefile.am
src/VISU_I/SALOME_GenericObjPointer.hh
src/VISU_I/VISUConfig.cc
src/VISU_I/VISUConfig.hh
src/VISU_I/VISU_ColoredPrs3d_i.cc
src/VISU_I/VISU_ColoredPrs3d_i.hh
src/VISU_I/VISU_DeformedShape_i.cc
src/VISU_I/VISU_GaussPoints_i.cc
src/VISU_I/VISU_GaussPoints_i.hh
src/VISU_I/VISU_Gen_i.cc
src/VISU_I/VISU_Mesh_i.cc
src/VISU_I/VISU_MultiResult_i.cc [new file with mode: 0644]
src/VISU_I/VISU_MultiResult_i.hh [new file with mode: 0644]
src/VISU_I/VISU_ResultUtils.cc [new file with mode: 0644]
src/VISU_I/VISU_ResultUtils.hh [new file with mode: 0644]
src/VISU_I/VISU_Result_i.cc
src/VISU_I/VISU_Result_i.hh
src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc
src/VISU_I/VISU_ScalarMap_i.cc
src/VISU_I/VISU_StreamLines_i.cc
src/VISU_I/VISU_Vectors_i.cc

index 560a870aa4dd468acebb00c954a720e513eeaedd..5bc063ed07b32e9b0dbd608c0731a02033f0fd02 100644 (file)
@@ -60,7 +60,8 @@ module VISU {
   enum Entity{ NODE, /*!< Node corresponds to a geometrical point. */
                EDGE, /*!< Edge corresponds to a geometrical line connecting two points. */
               FACE, /*!< Face corresponds to a geometrical plane bounded by several lines. */
-              CELL  /*!< Cell is a volumic element of a mesh */
+              CELL,  /*!< Cell is a volumic element of a mesh */
+              NONE  /*!< Indicates undefined entity value */
               };
 
   /*!
index 1c6fd8d8c8d547bbbdb5cefa861333472e93d737..2526962b7a6218e750fe04d04994cd0e5ff32182 100644 (file)
 #include <utility>
 
 
+//---------------------------------------------------------------
+VISU_Convertor
+::VISU_Convertor():
+  myIsDone(false)
+{}
+
+
+//---------------------------------------------------------------
+const std::string& 
+VISU_Convertor
+::GetName()
+{
+  return myName;
+}
+
+
+//---------------------------------------------------------------
+int
+VISU_Convertor
+::IsDone() const 
+{
+  return myIsDone; 
+}
+
 //---------------------------------------------------------------
 const VISU::TMeshMap& 
 VISU_Convertor
index 45edc030da4b94a5acddec9abb8c688ed96b1f6c..c5819c08a2853cb3f761a061370fe14614f0b67a 100644 (file)
 class VISU_CONVERTOR_EXPORT VISU_Convertor
 {
 public:
-  virtual 
-  ~VISU_Convertor()
-  {};
-  
   //! Get brief name of the corresponding source MED file
   virtual
   const std::string& 
-  GetName(){ return myName;}
+  GetName();
 
   //! Let known whether the source MED file parsed or not
   virtual
   int
-  IsDone() const { return myIsDone; }
+  IsDone() const;
 
   //! This method perform first parsing of MED file to get known what MED entities are pressent in it
   virtual
@@ -205,6 +201,8 @@ public:
   GenerateName(const std::string& theName, unsigned int theTimeId);
 
 protected:
+  VISU_Convertor();
+  
   std::string myName;
   VISU::TMeshMap myMeshMap;
   int myIsDone;
@@ -212,8 +210,8 @@ protected:
 
 extern "C"
 {
-VISU_CONVERTOR_EXPORT
   //! Instatiate proper VISU_Convertor subclass
+  VISU_CONVERTOR_EXPORT
   VISU_Convertor*
   CreateConvertor(const std::string& theFileName);
 };
index c2cd889314fd9b8f78a3ba473cc5b5578c4932c5..b71a5712b2e70c36873ad810a2b8d0596e6c0a29 100644 (file)
@@ -563,10 +563,8 @@ namespace
 
 //---------------------------------------------------------------
 VISU_Convertor_impl
-::VISU_Convertor_impl() 
-{
-  myIsDone = false;
-}
+::VISU_Convertor_impl()
+{}
 
 
 //---------------------------------------------------------------
index 31cf0d9d50fde8048f5e296f1b89124f51eb1d45..5cb621050c3b846b97732e15bfe6cc95d562c4c4 100644 (file)
@@ -1328,8 +1328,7 @@ VISU_MedConvertor
   myIsMinMaxDone(false),
   myMed(theMed)
 {
-  myFileInfo.setFile(QString(theFileName.c_str()));
-  myName = myFileInfo.baseName().latin1();
+  myName = theFileName;
 }
 
 
index e3834ab2d227e30816e83fb907673435e75e2a69..7b2c6b80177c8b5e2b5aa1767f9b622def18b813 100644 (file)
@@ -31,7 +31,6 @@
 #include "MED_GaussUtils.hxx"
 
 #include <boost/thread/mutex.hpp>
-#include <qfileinfo.h>
 
 namespace VISU
 {
@@ -357,7 +356,6 @@ public:
   BuildGroups();
 
 protected:
-  QFileInfo myFileInfo;
   MED::PWrapper myMed; // mpv : bug 13568: one med per converter
 
   virtual
index 7955acb06392663d38eea6fd83fed45bf7232c3a..311657fe2ed3c127daa5f09b3cd12d9ab040577f 100644 (file)
@@ -215,7 +215,6 @@ VisuGUI
       application()->putInfo( anInfo );
 
       QApplication::setOverrideCursor(Qt::waitCursor);
-      // MULTIPR: CreateResult
       VISU::Result_var aResult = GetVisuGen(this)->CreateResult( aFileInfo.filePath() );
 
       if (CORBA::is_nil(aResult.in())) {
@@ -2281,8 +2280,6 @@ VisuGUI
                 tr("MEN_CACHE_PROPERTIES"), "", 0, aParent, false,
                 this, SLOT(OnCacheProperties()));
 
-#ifdef ENABLE_MULTIPR
-  // MULTIPR
   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_MULTIPR_VIEW_FULL"));
   createAction( VISU_MULTIPR_FULL_RES, tr("MEN_MULTIPR_VIEW_FULL_RES"), QIconSet(aPixmap),
                 tr("MEN_MULTIPR_VIEW_FULL_RES"), "", 0, aParent, false,
@@ -2302,7 +2299,6 @@ VisuGUI
   createAction( VISU_MULTIPR_HIDE, tr("MEN_MULTIPR_VIEW_HIDE"), QIconSet(aPixmap),
                 tr("MEN_MULTIPR_VIEW_HIDE"), "", 0, aParent, false,
                 this, SLOT(OnMultiprViewHide()));
-#endif
 }
 
 void
@@ -2480,14 +2476,10 @@ VisuGUI
 
   mgr->insert( action( VISU_SELECTION_INFO ), -1, -1, -1 ); // Selection info
 
-#ifdef ENABLE_MULTIPR
-  // MULTIPR
   mgr->insert( action( VISU_MULTIPR_FULL_RES ), -1, -1, -1 );
   mgr->insert( action( VISU_MULTIPR_MED_RES ), -1, -1, -1 );
   mgr->insert( action( VISU_MULTIPR_LOW_RES ), -1, -1, -1 );
   mgr->insert( action( VISU_MULTIPR_HIDE ), -1, -1, -1 );
-#endif
-  
   
   // Rules
 
@@ -2663,14 +2655,11 @@ VisuGUI
   //aRule = "client='ObjectBrowser' and type='MEDFIELD'";
   //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
   
-#ifdef ENABLE_MULTIPR
-  // MULTIPR
-  aRule = "client='ObjectBrowser' and $type in {'VISU::TPART'}";
-  mgr->setRule( action( VISU_MULTIPR_FULL_RES ), aRule + " and selcount>=1", true );
-  mgr->setRule( action( VISU_MULTIPR_MED_RES ), aRule + " and selcount>=1", true );
-  mgr->setRule( action( VISU_MULTIPR_LOW_RES ), aRule + " and selcount>=1", true );
-  mgr->setRule( action( VISU_MULTIPR_HIDE), aRule + " and selcount>=1", true );
-#endif
+  aRule = "client='ObjectBrowser' and $type in {'VISU::TPART'} and selcount>=1";
+  mgr->setRule( action( VISU_MULTIPR_FULL_RES ), aRule, true );
+  mgr->setRule( action( VISU_MULTIPR_MED_RES ), aRule, true );
+  mgr->setRule( action( VISU_MULTIPR_LOW_RES ), aRule, true );
+  mgr->setRule( action( VISU_MULTIPR_HIDE), aRule, true );
 }
 
 //***************************************************************************
@@ -3458,42 +3447,38 @@ void VisuGUI::OnCacheProperties()
   aDlg->exec();
 }
 
-// MULTIPR
+
+//---------------------------------------------------------------
 void VisuGUI::OnMultiprViewFullRes()
 {
-#ifdef ENABLE_MULTIPR
-       OnMultiprChangeRes('F');
-#endif
+  OnMultiprChangeRes('F');
 }
 
-// MULTIPR
+
+//---------------------------------------------------------------
 void VisuGUI::OnMultiprViewMediumRes()
 {
-#ifdef ENABLE_MULTIPR
-       OnMultiprChangeRes('M');
-#endif
+  OnMultiprChangeRes('M');
 }
 
-// MULTIPR
+
+//---------------------------------------------------------------
 void VisuGUI::OnMultiprViewLowRes()
 {
-#ifdef ENABLE_MULTIPR
-       OnMultiprChangeRes('L');
-#endif
+  OnMultiprChangeRes('L');
 }
 
-// MULTIPR
+
+//---------------------------------------------------------------
 void VisuGUI::OnMultiprViewHide()
 {
-#ifdef ENABLE_MULTIPR
-       OnMultiprChangeRes('H');
-#endif
+  OnMultiprChangeRes('H');
 }
 
-// MULTIPR
-void VisuGUI::OnMultiprChangeRes(char resolution)
+
+//---------------------------------------------------------------
+void VisuGUI::OnMultiprChangeRes(char theResolution)
 {
-#ifdef ENABLE_MULTIPR
   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
   if (CheckLock(aCStudy,GetDesktop(this)))
     return;
@@ -3502,10 +3487,11 @@ void VisuGUI::OnMultiprChangeRes(char resolution)
   if(aSelectionInfo.empty())
     return;
 
-  //cout << "selection: #=" << aSelectionInfo.size() << endl;
+  typedef SALOME::GenericObjPtr<VISU::Result_i> TResultPtr;
+  typedef std::set<TResultPtr> TResultSet;
+  TResultSet aResultSet;
 
-  for (int i=0; i<aSelectionInfo.size(); i++)
-  {
+  for (int i=0; i < aSelectionInfo.size(); i++) {
     VISU::TSelectionItem aSelectionItem = aSelectionInfo[i];
 
     _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
@@ -3513,48 +3499,24 @@ void VisuGUI::OnMultiprChangeRes(char resolution)
       continue;
 
     VISU::Result_var aResult = FindResult( VISU::GetSObject( aSObject ).in() );
-    VISU::Result_i* result = dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult).in());
+    if(CORBA::is_nil(aResult.in()))
+      continue;
+    
+    VISU::Result_i* aCResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult).in());
+    if(!aCResult)
+      continue;
 
-    _PTR(GenericAttribute) anAttr;
-    if (aSObject->FindAttribute(anAttr, "AttributePixMap"))
-    {
-      _PTR(AttributePixMap) aPixMap(anAttr);
-      if ( aPixMap->HasPixMap() )
-      {
-        const char* oldIcon = aPixMap->GetPixMap().c_str();
-        if ( (strcmp(oldIcon, "ICON_MULTIPR_VIEW_FULL")   == 0) ||
-             (strcmp(oldIcon, "ICON_MULTIPR_VIEW_MEDIUM") == 0) ||
-             (strcmp(oldIcon, "ICON_MULTIPR_VIEW_LOW")    == 0) ||
-             (strcmp(oldIcon, "ICON_MULTIPR_VIEW_HIDE")   == 0) )
-        {
-          bool hasMediumOrLow = (strstr(aSObject->GetComment().c_str(), "res=FML") != NULL);
-
-          if (resolution == 'F') 
-          {
-            if (result != NULL) result->SetResolutionMultipr(aSObject->GetName().c_str(), 'F');
-            aPixMap->SetPixMap("ICON_MULTIPR_VIEW_FULL");
-          } 
-          else if ((resolution == 'M') && hasMediumOrLow) 
-          {
-            if (result != NULL) result->SetResolutionMultipr(aSObject->GetName().c_str(), 'M');
-            aPixMap->SetPixMap("ICON_MULTIPR_VIEW_MEDIUM");
-          } 
-          else if ((resolution == 'L') && hasMediumOrLow) 
-          {
-            if (result != NULL) result->SetResolutionMultipr(aSObject->GetName().c_str(), 'L');
-            aPixMap->SetPixMap("ICON_MULTIPR_VIEW_LOW"); 
-          }
-          else if (resolution == 'H') 
-          {
-            if (result != NULL) result->SetResolutionMultipr(aSObject->GetName().c_str(), 'H');
-            aPixMap->SetPixMap("ICON_MULTIPR_VIEW_HIDE");
-          }
-        }
-      }
-    }
+    aResultSet.insert(TResultPtr(aCResult));
+    aCResult->SetResolution(aSObject->GetName().c_str(), theResolution);
+  }
+
+  // To update all result observers
+  TResultSet::const_iterator anIter = aResultSet.begin();
+  for(; anIter != aResultSet.end(); anIter++){
+    const TResultPtr& aResultPtr = *anIter;
+    aResultPtr->UpdateObservers();
   }
 
   UpdateObjBrowser(this, false);
-#endif
 }
 
index 4f7379bbee246fb6a79faee3a5f93ffa04a9d885..82d03a414bb35dc43b717645b77359dcf1f0e36f 100644 (file)
@@ -485,7 +485,7 @@ void VisuGUI_InputPane::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs )
     VISU::GetSelectionMgr( myModule )->installFilter( myFieldFilter );
   
   // type of presentation and groups
-  VISU_Convertor* anInput = aResult->GetInput();
+  VISU::Result_i::PInput anInput = aResult->GetInput();
   const VISU::TMeshMap& aMeshMap = anInput->GetMeshMap();
   std::string aMeshName = thePrs->GetCMeshName();
   VISU::TMeshMap::const_iterator aMeshIter = aMeshMap.find(aMeshName);
index 043db8bd2131a78c5766810974035fd9085d0850..c46f165d9d469dce771b12abfeb93c746f0e0baa 100644 (file)
@@ -45,12 +45,15 @@ using namespace VISU;
 // Class: VisuGUI_Selection
 //////////////////////////////////////////////////
 
+
+//---------------------------------------------------------------
 QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const
 {
   QtxValue val( LightApp_Selection::param( ind, p ) );
   if ( !val.isValid() ) {
     if      ( p == "type"           ) val = QtxValue( type( ind ) );
     else if ( p == "nbComponents"   ) val = QtxValue( nbComponents( ind ) );
+    else if ( p == "resolution"   ) val = QtxValue( resolution( ind ) );
     else if ( p == "medEntity"   ) val = QtxValue( medEntity( ind ) );
     else if ( p == "medSource"   ) val = QtxValue( medSource( ind ) );
     else if ( p == "representation" ) val = QtxValue( representation( ind ) );
@@ -68,6 +71,8 @@ QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const
   return val;
 }
 
+
+//---------------------------------------------------------------
 // Macro for converting VISU enumeration items into corresponding strings
 #define ENUM2STRING( x, y ) \
   case y: \
@@ -134,6 +139,8 @@ QString VisuGUI_Selection::type( const int ind ) const
   return aResStr;
 }
 
+
+//---------------------------------------------------------------
 QString VisuGUI_Selection::nbComponents( const int ind ) const
 {
   QString aResStr;
@@ -151,6 +158,28 @@ QString VisuGUI_Selection::nbComponents( const int ind ) const
   return aResStr;
 }
 
+
+//---------------------------------------------------------------
+QString VisuGUI_Selection::resolution( const int ind ) const
+{
+  QString aResStr;
+  SalomeApp_Study* aStudy = GetStudy();
+  if ( !aStudy )
+    return aResStr;
+
+  VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind ));
+  VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject);
+
+  bool isExist;
+  QString aVal = VISU::Storable::FindValue(aMap,"myState",&isExist);
+  if ( isExist )
+    aResStr = aVal;
+
+  return aResStr;
+}
+
+
+//---------------------------------------------------------------
 QString VisuGUI_Selection::medEntity( const int ind ) const
 {
   SalomeApp_Study* aStudy = GetStudy();
@@ -451,6 +480,8 @@ struct TIsScalarMapActFunctor: TViewFunctor
   }
 };
 
+
+//---------------------------------------------------------------
 QString VisuGUI_Selection::isScalarMapAct( const int ind ) const
 {
   return TPopupDispatcher<TIsScalarMapActFunctor>()(myModule, entry(ind));
index 536ef59a94745cea92a066fa2a127a69e49b992a..aef189634ba258b32e69d37de82d82248ce1529d 100644 (file)
@@ -48,6 +48,7 @@ public:
 private:
   QString          type( const int ) const;
   QString          nbComponents( const int ) const;
+  QString          resolution( const int ) const;
   QString          medEntity( const int ) const;
   QString          medSource( const int ) const;
   QString          nbTimeStamps( const int ) const;
index 13c8046de98c9031e6eac71c6e13c799119e7f03..bf8d48e447e779a3d879a32f54355f979fa9f1b4 100644 (file)
@@ -460,7 +460,7 @@ VisuGUI_ScalarMapOnDeformedShapeDlg
   QString aTime("");
   VISU::TEntity anEntity = VISU::TEntity(theEntity);
   VISU::Result_i* theResult = myPrsCopy->GetCResult();
-  VISU::Result_i::TInput* anInput = theResult->GetInput();
+  VISU::Result_i::PInput anInput = theResult->GetInput();
   VISU::PField aField = anInput->GetField(myPrsCopy->GetCMeshName(),
                                          anEntity,
                                          theFieldName);
index f75be372213a7d488227f813c16b3b0076ea211d..2887c6d61815678e2f52e007b76606971283e15c 100644 (file)
@@ -31,6 +31,7 @@ salomeinclude_HEADERS = \
        VISUConfig.hh \
        VISU_Gen_i.hh \
        VISU_Result_i.hh \
+       VISU_MultiResult_i.hh \
        VISU_PrsObject_i.hh \
        VISU_Table_i.hh \
        VISU_Prs3d_i.hh \
@@ -53,8 +54,11 @@ salomeinclude_HEADERS = \
        SALOME_GenericObjPointer.hh
 
 libVISUEngineImpl_la_SOURCES = \
-       VISU_Result_i.cc \
        VISUConfig.cc \
+       VISU_Result_i.cc \
+       VISU_ResultUtils.cc \
+       VISU_MultiResult_i.cc \
+       VISU_CorbaMedConvertor.cxx \
        VISU_PrsObject_i.cc \
        VISU_Prs3d_i.cc \
        VISU_ColoredPrs3d_i.cc \
@@ -77,7 +81,6 @@ libVISUEngineImpl_la_SOURCES = \
        VISU_View_i.cc \
        VISU_Table_i.cc \
        VISU_Gen_i.cc \
-       VISU_CorbaMedConvertor.cxx \
        VISU_DumpPython.cc \
        SALOME_GenericObjPointer.cc
 
index e710a4f05c81129162cbf4bc64e9eab3e7cfec37..7284984924f5760df347c742460f2868774267ad 100644 (file)
@@ -153,6 +153,14 @@ namespace SALOME
   };
 }
 
+template<class T, class U> 
+inline 
+bool 
+operator<(SALOME::GenericObjPtr<T> const & a, SALOME::GenericObjPtr<U> const & b)
+{
+  return a.get() < b.get();
+}
+
 template<class T, class U> 
 inline
 bool 
index 0b7bad1fdee4a12af1bab758dbd32a89e1f57179..bcde9828c47e2c44098f4b942eee6f5af307fc7b 100644 (file)
 #include "SALOMEDSClient_AttributeIOR.hxx"
 
 #include "SalomeApp_Application.h"
+#include "SalomeApp_Study.h"
+
+#include "SALOME_Event.hxx"
+
 #include <qregexp.h>
 
 using namespace std;
@@ -57,7 +61,7 @@ namespace VISU{
     return GetSession()->resourceMgr();
   }
 
-  //===========================================================================
+  //---------------------------------------------------------------------------
 
   QMutex* Base_i::myMutex = NULL; //apo - &VISUMutex;
   CORBA::ORB_var Base_i::myOrb;
@@ -79,7 +83,7 @@ namespace VISU{
     return CORBA::string_dup(myID.c_str());
   }
 
-  //===========================================================================
+  //---------------------------------------------------------------------------
   static int mySCnt = 0;
   static QMutex aMutex(TRUE);
 
@@ -98,7 +102,7 @@ namespace VISU{
   }
 
 
-  //===========================================================================
+  //---------------------------------------------------------------------------
   static Storable::TCallbackMap VisuStoreMap;
 
   std::string 
@@ -361,6 +365,8 @@ namespace VISU{
     theStr<<output.latin1()<<";";
   }
 
+
+  //---------------------------------------------------------------
   void 
   Storable
   ::DataToStream(std::ostringstream& theStr, 
@@ -373,6 +379,8 @@ namespace VISU{
     theStr<<output.latin1()<<";";
   }
 
+
+  //---------------------------------------------------------------
   void
   Storable
   ::DataToStream(std::ostringstream& theStr, 
@@ -385,6 +393,8 @@ namespace VISU{
     theStr<<output.latin1()<<";";
   }
 
+
+  //---------------------------------------------------------------
   Storable* 
   Storable
   ::Create(SALOMEDS::SObject_ptr theSObject,
@@ -413,6 +423,8 @@ namespace VISU{
     return NULL;
   }
 
+
+  //---------------------------------------------------------------
   QString
   Storable
   ::FindValue(const TRestoringMap& theMap, 
@@ -434,6 +446,7 @@ namespace VISU{
   }
 
 
+  //---------------------------------------------------------------
   QString
   Storable
   ::FindValue(const TRestoringMap& theMap, 
@@ -448,7 +461,7 @@ namespace VISU{
   }
 
 
-  //===========================================================================
+  //---------------------------------------------------------------------------
   PortableServer::ServantBase_var
   GetServant(CORBA::Object_ptr theObject)
   {
@@ -464,7 +477,7 @@ namespace VISU{
   }
 
 
-  //===========================================================================
+  //---------------------------------------------------------------------------
   CORBA::Object_var 
   SObjectToObject(SALOMEDS::SObject_ptr theSObject)
   {
@@ -486,7 +499,7 @@ namespace VISU{
     return anObject;
   }
 
-  //===========================================================================
+  //---------------------------------------------------------------------------
   CORBA::Object_var
   ClientSObjectToObject(_PTR(SObject) theSObject)
   {
@@ -509,8 +522,7 @@ namespace VISU{
   }
 
 
-  //===========================================================================
-  //===========================================================================
+  //---------------------------------------------------------------------------
   std::string
   CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
                   const std::string& theFatherEntry, 
@@ -529,27 +541,27 @@ namespace VISU{
     else
       aNewSObject = aFather;
     SALOMEDS::GenericAttribute_var anAttr;
-    if(theIOR != ""){
+    if(theIOR != NO_IOR){
       anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeIOR");
       SALOMEDS::AttributeIOR_var aCustomAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
       aCustomAttr->SetValue(theIOR.c_str());
     }
-    if(theName != ""){
+    if(theName != NO_NAME){
       anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeName");
       SALOMEDS::AttributeName_var aCustomAttr = SALOMEDS::AttributeName::_narrow(anAttr);
       aCustomAttr->SetValue(theName.c_str());
     }
-    if(thePersistentRef != ""){
+    if(thePersistentRef != NO_PERFSITENT_REF){
       anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePersistentRef");
       SALOMEDS::AttributePersistentRef_var aCustomAttr = SALOMEDS::AttributePersistentRef::_narrow(anAttr);
       aCustomAttr->SetValue(thePersistentRef.c_str());
     }
-    if(theComment != ""){
+    if(theComment != NO_COMMENT){
       anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeString");
       SALOMEDS::AttributeString_var aCustomAttr = SALOMEDS::AttributeString::_narrow(anAttr);
       aCustomAttr->SetValue(theComment.c_str());
     }
-    if(theIconName != ""){
+    if(theIconName != NO_ICON){
       anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePixMap");
       SALOMEDS::AttributePixMap_var aCustomAttr = SALOMEDS::AttributePixMap::_narrow(anAttr);
       aCustomAttr->SetPixMap(theIconName.c_str());
@@ -580,27 +592,27 @@ namespace VISU{
       aNewSObject = aFather;
 
     _PTR(GenericAttribute) anAttr;
-    if (theIOR != "") {
+    if (theIOR != NO_IOR) {
       anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeIOR");
       _PTR(AttributeIOR) aCustomAttr (anAttr);
       aCustomAttr->SetValue(theIOR);
     }
-    if (theName != "") {
+    if (theName != NO_NAME) {
       anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeName");
       _PTR(AttributeName) aCustomAttr (anAttr);
       aCustomAttr->SetValue(theName);
     }
-    if (thePersistentRef != "") {
+    if (thePersistentRef != NO_PERFSITENT_REF) {
       anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePersistentRef");
       _PTR(AttributePersistentRef) aCustomAttr (anAttr);
       aCustomAttr->SetValue(thePersistentRef);
     }
-    if (theComment != "") {
+    if (theComment != NO_COMMENT) {
       anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeString");
       _PTR(AttributeString) aCustomAttr (anAttr);
       aCustomAttr->SetValue(theComment);
     }
-    if (theIconName != "") {
+    if (theIconName != NO_ICON) {
       anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePixMap");
       _PTR(AttributePixMap) aCustomAttr (anAttr);
       aCustomAttr->SetPixMap(theIconName);
@@ -612,6 +624,8 @@ namespace VISU{
     return aRet;
   }
 
+
+  //---------------------------------------------------------------
   QString 
   GenerateName(const string& theFmt, int theId)
   {
@@ -624,6 +638,7 @@ namespace VISU{
   }
 
 
+  //---------------------------------------------------------------
   SALOMEDS::StudyManager_var 
   GetStudyManager()
   {
@@ -637,15 +652,60 @@ namespace VISU{
   }
 
 
+  //---------------------------------------------------------------
   SALOMEDS::Study_var 
   GetDSStudy(_PTR(Study) theStudy)
   {
-    //std::string aStudyName = theStudy->Name();
-    //return GetStudyManager()->GetStudyByName(aStudyName.c_str());
     int aStudyID = theStudy->StudyId();
     return GetStudyManager()->GetStudyByID(aStudyID);
   }
 
+
+  //---------------------------------------------------------------
+  struct TGetStudyEvent: public SALOME_Event
+  {
+    int myStudyId;
+    
+    typedef _PTR(Study) TResult;
+    TResult myResult;
+    
+    TGetStudyEvent(int theStudyId):
+      myStudyId(theStudyId)
+    {}
+    
+    virtual
+    void
+    Execute()
+    {
+      SUIT_Session* aSession = SUIT_Session::session();
+      QPtrList<SUIT_Application> anApplications = aSession->applications();
+      QPtrListIterator<SUIT_Application> anIter (anApplications);
+      while (SUIT_Application* anApp = anIter.current()) {
+       ++anIter;
+       if (SUIT_Study* aSStudy = anApp->activeStudy()) {
+         if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
+           if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+             if (myStudyId == aCStudy->StudyId()) {
+               myResult = aCStudy;
+               break;
+             }
+           }
+         }
+       }
+      }
+    }
+  };
+  
+
+  //---------------------------------------------------------------
+  _PTR(Study) 
+  GetStudy(SALOMEDS::Study_var theStudy)
+  {
+    return ProcessEvent(new TGetStudyEvent(theStudy->StudyId()));
+  }
+
+
+  //---------------------------------------------------------------
   SALOMEDS::SObject_var 
   GetSObject( _PTR(SObject) obj )
   {
@@ -655,15 +715,18 @@ namespace VISU{
     return aSalomeDSStudy->FindObjectID( id.c_str() );
   }
 
+  //---------------------------------------------------------------
   _PTR(SObject) 
   GetClientSObject( SALOMEDS::SObject_var obj,
                    _PTR(Study) study )
   {
-    return study->FindObjectID( obj->GetID() );
+    CORBA::String_var anEntry = obj->GetID();
+    return study->FindObjectID( anEntry.in() );
 
   }
 
 
+  //---------------------------------------------------------------
   void
   RemoveFromStudy (SALOMEDS::SObject_ptr theSObject,
                   bool theIsAttrOnly,
@@ -707,6 +770,8 @@ namespace VISU{
     aStudyBuilder->RemoveObjectWithChildren(theSObject);
   }
 
+
+  //---------------------------------------------------------------
   void
   RemoveFromStudy (_PTR(SObject) theSObject,
                   bool theIsAttrOnly,
index ef3ff038d50b97784ab707a801e7e5c9fdd6289a..58206b2a31d6f63169f5b4af66cca3ebab2b97ba 100644 (file)
@@ -247,6 +247,12 @@ namespace VISU
   SALOMEDS::SComponent_var 
   FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument);
 
+  const char* const NO_ICON = "";
+  const char* const NO_IOR = "";
+  const char* const NO_NAME = "";
+  const char* const NO_PERFSITENT_REF = "";
+  const char* const NO_COMMENT = "";
+
   VISU_I_EXPORT
   std::string 
   CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
@@ -281,6 +287,10 @@ namespace VISU
   SALOMEDS::Study_var 
   GetDSStudy(_PTR(Study));
 
+  VISU_I_EXPORT
+  _PTR(Study) 
+  GetStudy(SALOMEDS::Study_var);
+
   VISU_I_EXPORT
   void
   RemoveFromStudy(SALOMEDS::SObject_ptr theSObject,
index 13246cfc774f8a97fde2485311a7c1aabbd10583..58423840c416cdb752cf3e9686fb9676f9e3bc5f 100644 (file)
@@ -114,6 +114,25 @@ VISU::ColoredPrs3d_i
   ProcessVoidEvent(new TRemoveFromStudy(this));
 }
 
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::UpdateFromResult(Result_i* theResult)
+{
+  try{
+    if(theResult == GetCResult()){
+      DoSetInput(false, false);
+      UpdateActors();
+    }
+  }catch(std::exception& exc){
+    INFOS("Follow exception was occured :\n"<<exc.what());
+  }catch(...){
+    INFOS("Unknown exception was occured!");
+  }
+}
+
+
 //---------------------------------------------------------------
 bool 
 VISU::ColoredPrs3d_i
@@ -162,6 +181,7 @@ VISU::ColoredPrs3d_i
     myPreviousEntity = myEntity;
     myPreviousFieldName = myFieldName;
     myPreviousTimeStampNumber = myTimeStampNumber;
+    GetCResult()->ConnectObserver(this, myResultConnection);
   }catch(std::exception& exc){
     INFOS("Follow exception was occured :\n"<<exc.what());
     OnRestoreInput();
index 72ddb6fd916f9fe19baf25fe87c3afabc38c2b30..3a5d0202f5d8bfc2a6e50baad94193f62812f63d 100644 (file)
@@ -28,6 +28,8 @@
 #define VISU_ColoredPrs3d_i_HeaderFile
 
 #include "VISU_Prs3d_i.hh"
+#include "VISU_Result_i.hh"
+#include "VISU_BoostSignals.h"
 
 class VISU_ColoredPL;
 
@@ -35,6 +37,7 @@ namespace VISU
 {
   //----------------------------------------------------------------------------
   class VISU_I_EXPORT ColoredPrs3d_i : public virtual POA_VISU::ColoredPrs3d,
+                                      public virtual TResultObserver,
                                       public virtual Prs3d_i
   {
     ColoredPrs3d_i(const ColoredPrs3d_i&);
@@ -59,6 +62,12 @@ namespace VISU
     void
     RemoveFromStudy();
 
+    //----------------------------------------------------------------------------
+    //! To update the presentation from result in automatic way
+    virtual
+    void
+    UpdateFromResult(Result_i* theResult);
+
     //----------------------------------------------------------------------------
     virtual
     void
@@ -468,6 +477,8 @@ namespace VISU
     CORBA::Long myTimeStampNumber;
     CORBA::Long myPreviousTimeStampNumber;
 
+    boost::signalslib::connection myResultConnection;
+
     bool myIsTimeStampFixed;
 
     PField myField;
index 805cbd606732885627c80f7a1baa937a63fd6fab..4fb0f8b33a9ad1a4b369d1c7d703418b16b42e7f 100644 (file)
@@ -63,7 +63,7 @@ VISU::DeformedShape_i
                                             theTimeStampNumber,
                                             theIsMemoryCheck);
     if(aResult){
-      VISU::Result_i::TInput* anInput = theResult->GetInput();
+      VISU::Result_i::PInput anInput = theResult->GetInput();
       VISU::PField aField = anInput->GetField(theMeshName,
                                              (VISU::TEntity)theEntity,
                                              theFieldName);
index 679dd5d7c61ccd0daf63eb9f9e9c9d275ce49ea3..be1570a5be6245f1f38d20ec34dc151272140767 100644 (file)
 #include <vtkTextProperty.h>
 #include <vtkProperty.h>
 
-#ifdef ENABLE_MULTIPR
-#include "MULTIPR_API.hxx"
-#endif
-
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
 #else
@@ -74,7 +70,10 @@ VISU::GaussPoints_i
     return aResult;
   try{
     bool anIsEstimated = true;
-    VISU::Result_i::TInput* anInput = theResult->GetInput();
+    VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName,
+                                                        theEntity,
+                                                        theFieldName,
+                                                        theTimeStampNumber);
     size_t aSize = anInput->GetTimeStampOnGaussPtsSize(theMeshName,
                                                       (VISU::TEntity)theEntity,
                                                       theFieldName,
@@ -615,60 +614,24 @@ void
 VISU::GaussPoints_i
 ::DoSetInput(bool theIsInitilizePipe, bool theReInit)
 {
-  static string aStrPrev = "";
-  static VISU::Result_i::TInput* anInputPrev = NULL;
-
-  // MULTIPR
-  VISU::Result_i::TInput* anInput = NULL;
-#ifdef ENABLE_MULTIPR
-  if (GetCResult()->IsDistributedMEDMultipr())
-  {        
-    vector<string> aListMEDFiles = GetCResult()->GetCurrentRepresentationMultipr();
-
-    string aStrCurrent = "";
-    for (unsigned i = 0 ; i < aListMEDFiles.size() ; i++)
-    {
-      aStrCurrent +=aListMEDFiles[i];
-    }
-    aStrCurrent += GetCMeshName();
-    aStrCurrent += GetCFieldName();
-    if (aStrPrev != aStrCurrent)
-    {        
-      if (anInputPrev != NULL) delete anInputPrev;
-
-      char aTmpFilename[256];
-      sprintf(aTmpFilename, "__tmp.med");
-
-      int res = multipr::merge(aListMEDFiles, GetCMeshName().c_str(), GetCFieldName().c_str(), aTmpFilename);
-      if (res == 0) throw std::runtime_error("empty mesh"); 
-
-      anInput = CreateConvertor(aTmpFilename);
-      anInput->Build();
-      anInputPrev = anInput;
-
-      aStrPrev = aStrCurrent;
-    }
-    else
-    {
-      anInput = anInputPrev;
-    }     
-  }
-  else
-#endif
-  {
-    anInput = GetCResult()->GetInput();
-  }
-
+  VISU::Result_i::PInput anInput = GetCResult()->GetInput(GetCMeshName(),
+                                                         GetEntity(),
+                                                         GetCFieldName(),
+                                                         GetTimeStampNumber());
   if(!anInput)
     throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!");
 
-  SetField(anInput->GetField(GetCMeshName(),GetTEntity(),GetCFieldName()));
+  SetField(anInput->GetField(GetCMeshName(),
+                            GetTEntity(),
+                            GetCFieldName()));
   if(!GetField()) 
     throw std::runtime_error("There is no Field with the parameters !!!");
 
   VISU::PGaussPtsIDMapper aGaussPtsIDMapper =
-    anInput->GetTimeStampOnGaussPts(GetCMeshName(),GetTEntity(),GetCFieldName(),GetTimeStampNumber());
-
+    anInput->GetTimeStampOnGaussPts(GetCMeshName(),
+                                   GetTEntity(),
+                                   GetCFieldName(),
+                                   GetTimeStampNumber());
   if(!aGaussPtsIDMapper) 
     throw std::runtime_error("There is no TimeStamp with the parameters !!!");
 
@@ -676,7 +639,6 @@ VISU::GaussPoints_i
   if(theIsInitilizePipe){
     GetSpecificPL()->Init();
   }
-  GetCResult()->MinMaxConnect(this);
 
   // To update scalar range according to the new input
   if(!IsTimeStampFixed() || theReInit)
@@ -1044,12 +1006,3 @@ VISU::GaussPoints_i
 {
   return mySpacing;
 }
-
-//----------------------------------------------------------------------------
-void
-VISU::GaussPoints_i
-::UpdateMinMax()
-{
-  MinMaxCunsomer::UpdateMinMax();
-  UpdateActors();
-}
index b4b150ece0d70d0cb71e963afed74095656f4e4d..bfe90d1c281ef08d2ed4ae34a6ef13d05df888b6 100644 (file)
@@ -27,7 +27,6 @@
 #ifndef VISU_GaussPoints_i_HeaderFile
 #define VISU_GaussPoints_i_HeaderFile
 
-#include "VISU_Result_i.hh"
 #include "VISU_ColoredPrs3d_i.hh"
 #include "VISU_GaussPtsActorFactory.h"
 
@@ -40,9 +39,8 @@ namespace VISU
 {
   //! Class of the Gauss Points presentation.
   class VISU_I_EXPORT GaussPoints_i : public virtual POA_VISU::GaussPoints,
-                       public virtual VISU::TGaussPtsActorFactory,
-                       public virtual MinMaxCunsomer,
-                       public virtual ColoredPrs3d_i
+                                     public virtual TGaussPtsActorFactory,
+                                     public virtual ColoredPrs3d_i
   {
     static int myNbPresent;
     GaussPoints_i(const GaussPoints_i&);
@@ -250,11 +248,6 @@ namespace VISU
     void
     SetSourceRange();
 
-    //! To update the min / max automatically
-    virtual
-    void
-    UpdateMinMax();
-
     VISU_GaussPointsPL* 
     GetSpecificPL() const
     { 
index dcd5ae50ae47d5c5e097de87beddacb2ef89b5c2..cddc42c436282231ab82aca837400564a73bcd0b 100644 (file)
@@ -646,9 +646,9 @@ namespace VISU
       return Result::_nil();
     Mutex mt(myMutex);
     aFileInfo.setFile(theFileName);
-    Result_i* pResult = new Result_i(myStudyDocument,
-                                    Result_i::eFile,
-                                    Result_i::eImportFile);
+    Result_i* pResult = Result_i::New(myStudyDocument,
+                                     Result_i::eFile,
+                                     Result_i::eImportFile);
     if(pResult->Create(theFileName) != NULL)
       return pResult->_this();
     else{
@@ -667,10 +667,10 @@ namespace VISU
       return Result::_nil();
     Mutex mt(myMutex);
     aFileInfo.setFile(theFileName);
-    Result_i* pResult = new Result_i(myStudyDocument,
-                                    Result_i::eFile,
-                                    Result_i::eImportFile,
-                                    false);
+    Result_i* pResult = Result_i::New(myStudyDocument,
+                                     Result_i::eFile,
+                                     Result_i::eImportFile,
+                                     false);
     if(pResult->Create(theFileName) != NULL)
       return pResult->_this();
     else{
@@ -690,9 +690,9 @@ namespace VISU
     Mutex mt(myMutex);
     VISU::Result_var aResult;
     aFileInfo.setFile(theFileName);
-    Result_i* pResult = new Result_i(myStudyDocument,
-                                    Result_i::eRestoredFile,
-                                    Result_i::eCopyAndImportFile);
+    Result_i* pResult = Result_i::New(myStudyDocument,
+                                     Result_i::eRestoredFile,
+                                     Result_i::eCopyAndImportFile);
     if(pResult->Create(theFileName) != NULL)
       aResult = pResult->_this();
     return aResult._retn();
@@ -707,9 +707,9 @@ namespace VISU
     if (myStudyDocument->GetProperties()->IsLocked())
       return Result::_nil();
     Mutex mt(myMutex);
-    Result_i* pResult = new Result_i(myStudyDocument,
-                                    Result_i::eComponent,
-                                    Result_i::eImportMed);
+    Result_i* pResult = Result_i::New(myStudyDocument,
+                                     Result_i::eComponent,
+                                     Result_i::eImportMed);
     if (pResult->Create(theMedSObject) != NULL) {
       return pResult->_this();
     } else {
@@ -727,9 +727,9 @@ namespace VISU
     if (myStudyDocument->GetProperties()->IsLocked())
       return Result::_nil();
     Mutex mt(myMutex);
-    Result_i* pResult = new Result_i(myStudyDocument,
-                                    Result_i::eComponent,
-                                    Result_i::eImportMedField);
+    Result_i* pResult = Result_i::New(myStudyDocument,
+                                     Result_i::eComponent,
+                                     Result_i::eImportMedField);
     if (pResult->Create(theField) != NULL) {
       return pResult->_this();
     } else {
@@ -1209,16 +1209,18 @@ namespace VISU
     return false;
   }
 
-  SALOMEDS::TMPFile* VISU_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {
+  SALOMEDS::TMPFile* 
+  VISU_Gen_i
+  ::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) 
+  {
     Mutex mt(myMutex);
     theObjectID = 0;
     SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
     SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
 
-    PortableServer::POA_ptr aPOA = GetPOA();
-
     SALOMEDS::GenericAttribute_var anAttr;
-    if (!theObject->FindAttribute(anAttr,"AttributeIOR")) return NULL;
+    if (!theObject->FindAttribute(anAttr,"AttributeIOR")) 
+      return NULL;
     SALOMEDS::AttributeIOR_var anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
     CORBA::Object_var aCorbaObj;
     try {
@@ -1245,7 +1247,7 @@ namespace VISU
     stmOut2<<aStr<<endl;
     stmOut2.close();
 
-    if (Result_i* aResultObj = dynamic_cast<Result_i*>(aPOA->reference_to_servant(aCorbaObj))) {
+    if (Result_i* aResultObj = dynamic_cast<Result_i*>(GetServant(aCorbaObj).in())) {
       string aFileName = string(SALOMEDS_Tool::GetNameFromPath(theObject->GetStudy()->URL())) + "_";
       if(strlen(aFileName.c_str()) == 1) aFileName="";
       const QFileInfo& aFileInfo = aResultObj->GetFileInfo();
index 46f3b1511271fa3afd43a18915c3c73f937672f0..5df41e26ef7618508f1985433fde49ef8d589ca9 100644 (file)
@@ -214,7 +214,7 @@ VISU::Mesh_i
     aRestoringMap["myMeshName"] = GetCMeshName();
 
     VISU::PUnstructuredGridIDMapper anIDMapper;
-    VISU::Result_i::TInput* anInput = GetCResult()->GetInput();
+    VISU::Result_i::PInput anInput = GetCResult()->GetInput();
     switch(myType){
     case VISU::TENTITY :
       anIDMapper = anInput->GetMeshOnEntity(aMeshName,
diff --git a/src/VISU_I/VISU_MultiResult_i.cc b/src/VISU_I/VISU_MultiResult_i.cc
new file mode 100644 (file)
index 0000000..012c00b
--- /dev/null
@@ -0,0 +1,628 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//  File   : VISU_MultiResult_i.cc
+//  Author : Alexey PETROV
+//  Module : VISU
+
+#ifdef ENABLE_MULTIPR
+
+#include "VISU_MultiResult_i.hh"
+#include "VISU_ResultUtils.hh"
+
+#include "VISU_Convertor.hxx"
+
+#include "MULTIPR_API.hxx"
+#include "MULTIPR_Obj.hxx"
+
+#include "SALOMEDS_Tool.hxx"
+
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#include <strstream>
+
+
+namespace VISU
+{
+  //---------------------------------------------------------------
+  inline
+  std::string
+  ExtractMainPart(const std::string& thePartName)
+  {
+    size_t aPos = thePartName.rfind('_');
+    if(aPos == std::string::npos)
+      return thePartName;
+
+    std::string aSuffix = thePartName.substr(aPos);
+    if(aSuffix == "_MED" || aSuffix == "_LOW")
+      return thePartName.substr(0, aPos);
+
+    return thePartName;
+  }
+
+
+  //---------------------------------------------------------------
+  inline
+  bool
+  IsSubString(const std::string& theSource,
+             const std::string& theSubString)
+  {
+    return theSource.rfind(theSubString) != std::string::npos;
+  }
+
+
+  //---------------------------------------------------------------
+  inline
+  bool
+  IsMediumResolution(const std::string& thePartName)
+  {
+    return IsSubString(thePartName, "_MED");
+  }
+
+
+  //---------------------------------------------------------------
+  inline
+  bool
+  IsLowResolution(const std::string& thePartName)
+  {
+    return IsSubString(thePartName, "_LOW");
+  }
+
+
+  //---------------------------------------------------------------
+  inline
+  bool
+  IsFullResolution(const std::string& thePartName)
+  {
+    return !IsMediumResolution(thePartName)  && !IsLowResolution(thePartName);
+  }
+
+
+  //---------------------------------------------------------------
+  typedef std::set<MultiResult_i::TPartName> TSubParts;
+  typedef std::map<MultiResult_i::TPartName, TSubParts> TMain2SubParts;
+
+  inline
+  std::string
+  GetResolutions(const TMain2SubParts& theMain2SubParts,
+                const std::string& thePartName)
+  {
+    std::string aResolution = "F";
+
+    MultiResult_i::TPartName aMainPart = ExtractMainPart(thePartName);
+    TMain2SubParts::const_iterator anIter = theMain2SubParts.find(aMainPart);
+    if(anIter != theMain2SubParts.end()){
+      const TSubParts& aSubParts = anIter->second;
+
+      if(aSubParts.find(aMainPart + "_LOW") != aSubParts.end())
+       aResolution += "L";
+
+      if(aSubParts.find(aMainPart + "_MED") != aSubParts.end())
+       aResolution += "M";
+    }
+    return aResolution;
+  }
+
+
+  //---------------------------------------------------------------
+  inline
+  MultiResult_i::TResolutionID
+  GetResolutionID(const TMain2SubParts& theMain2SubParts,
+                 const std::string& thePartName)
+  {
+    std::string aResolutions = GetResolutions(theMain2SubParts,
+                                             thePartName);
+    if(aResolutions.find('L') != std::string::npos)
+      return 'L';
+
+    if(aResolutions.find('M') != std::string::npos)
+      return 'M';
+
+    return 'F';
+  }
+
+
+  //---------------------------------------------------------------
+  inline
+  std::string
+  GetIconName(const TMain2SubParts& theMain2SubParts,
+             const std::string& thePartName)
+  {
+    MultiResult_i::TResolutionID aResolutionID = GetResolutionID(theMain2SubParts,
+                                                                thePartName);
+    if(aResolutionID == 'L')
+      return "ICON_MULTIPR_VIEW_LOW";
+
+    if(aResolutionID == 'M')
+      return "ICON_MULTIPR_VIEW_MEDIUM";
+
+    return "ICON_MULTIPR_VIEW_FULL";
+  }
+
+
+  //---------------------------------------------------------------
+  void 
+  BuildParts(Result_i* theResult,
+            Result_i::PInput theInput,
+            const QFileInfo& theMPFileInfo,
+            MultiResult_i::TPartName2FileName* thePartName2FileName,
+            MultiResult_i::TPartName2ResolutionID* thePartName2ResolutionID,
+            CORBA::Boolean* theIsDone,
+            CORBA::Boolean theIsBuild,
+            CORBA::Boolean theIsAtOnce,
+            _PTR(Study) theStudy)
+  {
+    if(!theIsBuild || *theIsDone)
+      return;
+
+    // if MED file is not a distributed MED file (created with MULTIPR),
+    // then it is not necessary to build parts
+    if (theMPFileInfo.filePath().isEmpty())
+      return;
+
+    try {
+      multipr::Obj aMultiprObj;
+      aMultiprObj.create(theMPFileInfo.filePath().latin1());
+      if (aMultiprObj.isValidDistributedMEDFile()) {
+       const VISU::TMeshMap& aMeshMap = theInput->GetMeshMap();
+       VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
+       const VISU::PMesh& aMesh = aMeshMapIter->second;
+
+       typedef std::vector<MultiResult_i::TPartName> TParts;
+       TParts aParts = aMultiprObj.getParts();
+
+       QString aComment = "Sub-parts: #";
+       aComment += QString::number(aParts.size());
+
+       CreateAttributes(theStudy,
+                        aMesh->myPartsEntry,
+                        NO_ICON,
+                        NO_IOR,
+                        "Parts",
+                        NO_PERFSITENT_REF,
+                        aComment.latin1(),
+                        false);
+
+       MultiResult_i::TPartName2FileName& aPartName2FileName = *thePartName2FileName;
+       MultiResult_i::TPartName2ResolutionID& aPartName2ResolutionID = *thePartName2ResolutionID;
+
+       TMain2SubParts aMain2SubParts;
+
+       for (size_t aPartID = 0 ; aPartID < aParts.size() ; aPartID++) {
+         const MultiResult_i::TPartName& aPartName = aParts[aPartID];
+         MultiResult_i::TPartName aMainPart = ExtractMainPart(aPartName);
+         aMain2SubParts[aMainPart].insert(aPartName);
+       }
+
+       std::string aLastEntry;
+       for (size_t aPartID = 0 ; aPartID < aParts.size() ; aPartID++) {
+         const MultiResult_i::TPartName& aPartName = aParts[aPartID];
+         std::string aPartInfo = aMultiprObj.getPartInfo(aPartName.c_str());
+
+         std::istrstream anOutputStream(aPartInfo.c_str());
+         std::string aMeshName;
+         anOutputStream>>aMeshName;
+
+         int anID;
+         anOutputStream>>anID;
+
+         std::string aName;
+         anOutputStream>>aName;
+
+         std::string aPath;
+         anOutputStream>>aPath;
+
+         std::string aFileName;
+         anOutputStream>>aFileName;
+
+         aPartName2FileName[aName] = aFileName;
+
+         QString aComment = "";
+         std::string aResoltutions = GetResolutions(aMain2SubParts, aName);
+         if ( IsFullResolution(aName) ) {
+           std::string anIconName = GetIconName(aMain2SubParts, aName);
+           MultiResult_i::TResolutionID aResolutionID = GetResolutionID(aMain2SubParts, aName);
+           aComment.sprintf("myComment=PART;myFile=%s;myResolutions=%s;myState=%c", 
+                            aFileName.c_str(), aResoltutions.c_str(), aResolutionID); 
+           aLastEntry = CreateAttributes(theStudy,
+                                         aMesh->myPartsEntry,
+                                         anIconName,
+                                         NO_IOR,
+                                         aName,
+                                         NO_PERFSITENT_REF,
+                                         aComment.latin1(),
+                                         true);
+           aPartName2ResolutionID[aName] = aResolutionID;
+         } else {
+           aComment.sprintf("myComment=PART;myFile=%s;myResolutions=%s", 
+                            aFileName.c_str(), aResoltutions.c_str()); 
+           CreateAttributes(theStudy,
+                            aLastEntry,
+                            NO_ICON,
+                            NO_IOR,
+                            aName,
+                            NO_PERFSITENT_REF,
+                            aComment.latin1(),
+                            true);
+         }
+       }
+      } else {
+       INFOS("invalid distributed MED file"); 
+      }
+      *theIsDone = true;
+    }catch(std::exception& exc){
+      INFOS("Follow exception was occured :\n"<<exc.what());
+    }catch(...){
+      INFOS("Unknown exception was occured!");
+    }
+
+    ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(), theIsDone));
+  }
+
+
+  //---------------------------------------------------------------
+}
+
+
+//---------------------------------------------------------------
+VISU::MultiResult_i
+::MultiResult_i (SALOMEDS::Study_ptr theStudy,
+                const ESourceId& theSourceId,
+                const ECreationId& theCreationId,
+                CORBA::Boolean theIsBuildImmediately,
+                CORBA::Boolean theIsBuildFields,
+                CORBA::Boolean theIsBuildMinMax,
+                CORBA::Boolean theIsBuildGroups):
+  Result_i(theStudy,
+          theSourceId,
+          theCreationId,
+          theIsBuildImmediately,
+          theIsBuildFields,
+          theIsBuildMinMax,
+          theIsBuildGroups)
+{}
+
+
+//---------------------------------------------------------------
+size_t
+VISU::MultiResult_i
+::IsPossible()
+{
+  return TSuperClass::IsPossible();
+}
+
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::MultiResult_i
+::Build(SALOMEDS::SObject_ptr theSObject,
+       CORBA::Boolean theIsAtOnce)
+{
+  if(!TSuperClass::Build(theSObject, theIsAtOnce))
+    return NULL;
+
+  if(IsDone())
+    return this;
+
+  if(theIsAtOnce){
+    BuildParts(this,
+              GetInput(),
+              myMPFileInfo,
+              &myPartName2FileName,
+              &myPartName2ResolutionID,
+              &myIsPartsDone,
+              myIsBuildParts,
+              theIsAtOnce,
+              myStudy);
+  }
+
+  return this;
+}
+
+
+//---------------------------------------------------------------
+void
+VISU::MultiResult_i
+::BuildDataTree(const std::string& theResultEntry)
+{
+  BuildEntities(this,
+               GetInput(),
+               &myIsEntitiesDone,
+               theResultEntry,
+               false,
+               myIsBuildGroups,
+               myIsBuildFields,
+               myIsBuildParts,
+               myStudy);
+  {
+    boost::thread aThread(boost::bind(&BuildParts,
+                                     this,
+                                     GetInput(),
+                                     myMPFileInfo,
+                                     &myPartName2FileName,
+                                     &myPartName2ResolutionID,
+                                     &myIsPartsDone,
+                                     myIsBuildParts,
+                                     false,
+                                     myStudy));
+  }
+  {
+    boost::thread aThread(boost::bind(&BuildGroups,
+                                     this,
+                                     GetInput(),
+                                     &myIsGroupsDone,
+                                     myIsBuildGroups,
+                                     false,
+                                     myStudy));
+  }
+  {
+    boost::thread aThread(boost::bind(&BuildFieldDataTree,
+                                     this,
+                                     GetInput(),
+                                     &myIsFieldsDone,
+                                     myIsBuildFields,
+                                     &myIsMinMaxDone,
+                                     myIsBuildMinMax,
+                                     myStudy));
+  }
+}
+
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::MultiResult_i
+::Create(const char* theFileName)
+{
+  QFileInfo aFileInfo(theFileName);
+  QString aTargetFileName = aFileInfo.filePath();
+  if(aTargetFileName.endsWith("_grains_maitre.med")){
+    // retrieve source MED file (sequential MED file)
+    FILE* aFile = fopen(theFileName, "rt");
+    QString aSourceFileName("");
+    char aBuf[1024];
+    while (!feof(aFile)) {
+      fgets(aBuf, 1024, aFile);
+      char* strTag = NULL;
+      if ((aBuf[0] == '#') && ((strTag = strstr(aBuf, "[SOURCE]=")) != NULL)) {
+       char aFileName[256];
+       int ret = sscanf(strTag, "[SOURCE]=%s", aFileName);
+       if (ret == 1) {
+         aSourceFileName = aFileName;
+         break;
+       }
+      }
+    }
+    fclose(aFile);
+    if (aSourceFileName.isEmpty()) 
+      throw std::runtime_error("distributed MED file; bad format"); 
+
+    myMPFileInfo.setFile(theFileName);
+    aTargetFileName = aSourceFileName;
+    myIsBuildParts = true;
+  }
+
+  return TSuperClass::Create(aTargetFileName);
+}
+
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::MultiResult_i
+::Restore(SALOMEDS::SObject_ptr theSObject,
+         const Storable::TRestoringMap& theMap,
+         const string& thePrefix)
+{
+  return TSuperClass::Restore(theSObject,
+                             theMap,
+                             thePrefix);
+}
+
+
+//---------------------------------------------------------------
+CORBA::Boolean 
+VISU::MultiResult_i
+::IsDone() 
+{
+  return TSuperClass::IsDone() && 
+    (myIsBuildParts? myIsPartsDone: true);
+}
+
+
+//---------------------------------------------------------------
+void 
+VISU::MultiResult_i
+::ToStream(std::ostringstream& theStr)
+{
+  TSuperClass::ToStream(theStr);
+}
+
+
+//---------------------------------------------------------------
+VISU::MultiResult_i
+::~MultiResult_i()
+{}
+
+
+//---------------------------------------------------------------
+void
+VISU::MultiResult_i
+::SetResolution(const std::string& theName, 
+               TResolutionID theNewResolution)
+{
+  TPartName2FileName::iterator anIter = myPartName2FileName.find(theName);
+  if(anIter == myPartName2FileName.end())
+    return;
+
+  TResolutionID& aNewResolution = myPartName2ResolutionID[theName];
+  if(aNewResolution == theNewResolution)
+    return;
+
+  aNewResolution = theNewResolution;
+
+  VISU::Storable::TRestoringMap aRestoringMap;
+  const TFileName& aFileName = anIter->second;
+  aRestoringMap["myComment"] = "PART";
+  aRestoringMap["myFile"] = aFileName;
+  std::string aFatherEntry = GetEntry(aRestoringMap);
+
+  std::string anIconName = "ICON_MULTIPR_VIEW_HIDE";
+  if(theNewResolution == 'F')
+    anIconName = "ICON_MULTIPR_VIEW_FULL";
+  else if(theNewResolution == 'M')
+    anIconName = "ICON_MULTIPR_VIEW_MEDIUM";
+  else if(theNewResolution == 'L')
+    anIconName = "ICON_MULTIPR_VIEW_LOW";
+
+  _PTR(Study) aStudy = GetStudy();
+  _PTR(SObject) aSObject = aStudy->FindObjectID(aFatherEntry);
+  aRestoringMap = Storable::GetStorableMap(aSObject);
+
+  std::ostrstream anOutputStream;
+  anOutputStream<<"myComment=PART;";
+  anOutputStream<<"myFile="<<aFileName<<";";
+  anOutputStream<<"myResolutions="<<aRestoringMap["myResolutions"]<<";";
+  anOutputStream<<"myState="<<theNewResolution;
+
+  CreateAttributes(aStudy,
+                  aFatherEntry,
+                  anIconName,
+                  NO_IOR,
+                  NO_NAME,
+                  NO_PERFSITENT_REF,
+                  anOutputStream.str(),
+                  false);
+}
+
+
+namespace VISU
+{
+  //---------------------------------------------------------------
+  inline
+  void
+  UpdateRepresentationKey(const MultiResult_i::TPartName2FileName& thePartName2FileName,
+                         MultiResult_i::TRepresentationKey& theRepresentationKey,
+                         const std::string& thePartName)
+  {
+    MultiResult_i::TPartName2FileName::const_iterator anIterator = thePartName2FileName.find(thePartName);
+    if (anIterator != thePartName2FileName.end()){
+      const MultiResult_i::TFileName& aFileName = anIterator->second;
+      theRepresentationKey.insert(aFileName);
+    }
+  }
+
+
+  //---------------------------------------------------------------
+  MultiResult_i::TRepresentationKey
+  GetRepresentation(const MultiResult_i::TPartName2FileName& thePartName2FileName,
+                   const MultiResult_i::TPartName2ResolutionID& thePartName2ResolutionID)
+  {
+    // name of selected parts
+    MultiResult_i::TRepresentationKey aRepresentationKey;
+
+    // for each part of the mesh
+    MultiResult_i::TPartName2ResolutionID::const_iterator anIter = thePartName2ResolutionID.begin();
+    for ( ; anIter != thePartName2ResolutionID.end() ; anIter++) {
+      const MultiResult_i::TPartName& aPartName = anIter->first;
+      const MultiResult_i::TResolutionID& aResolutionID = anIter->second;
+      if(aResolutionID == 'F') 
+       UpdateRepresentationKey(thePartName2FileName, aRepresentationKey, aPartName);
+      if(aResolutionID == 'M') 
+       UpdateRepresentationKey(thePartName2FileName, aRepresentationKey, aPartName + "_MED");
+      else if(aResolutionID == 'L') 
+       UpdateRepresentationKey(thePartName2FileName, aRepresentationKey, aPartName + "_LOW");
+    }
+    return aRepresentationKey;
+  }
+
+
+  //---------------------------------------------------------------
+  bool 
+  UseInitialInput(const MultiResult_i::TPartName2FileName& thePartName2FileName,
+                 const MultiResult_i::TPartName2ResolutionID& thePartName2ResolutionID)
+  {
+    bool aResult = true;
+    MultiResult_i::TPartName2FileName::const_iterator anIter = thePartName2FileName.begin();
+    for ( ; anIter != thePartName2FileName.end() ; anIter++) {
+      const MultiResult_i::TPartName& aPartName = anIter->first;
+      if(IsFullResolution(aPartName)){
+       MultiResult_i::TPartName2ResolutionID::const_iterator anIter2 = thePartName2ResolutionID.find(aPartName);
+       if(anIter2 != thePartName2ResolutionID.end()){
+         const MultiResult_i::TResolutionID& aResolutionID = anIter2->second;
+         if(aResolutionID == 'F')
+           continue;
+       }
+       aResult = false;
+       break;
+      }
+    }
+    return aResult;
+  }
+}
+
+
+//---------------------------------------------------------------
+VISU::Result_i::PInput
+VISU::MultiResult_i
+::GetInput(const std::string& theMeshName, 
+          VISU::Entity theEntity,
+          const std::string& theFieldName, 
+          CORBA::Long theTimeStampNumber) 
+{
+  if(theEntity == NONE) // If client wants use initial behaviour
+    return TSuperClass::GetInput();
+
+  if(!myIsPartsDone) // If corresponding data is not ready yet
+    return TSuperClass::GetInput();
+
+  if(UseInitialInput(myPartName2FileName, myPartName2ResolutionID)) 
+    return TSuperClass::GetInput();
+
+  MultiResult_i::TRepresentationKey aRepresentationKey = 
+    GetRepresentation(myPartName2FileName, myPartName2ResolutionID);
+
+  typedef std::vector<TFileName> TFileNames;
+  TFileNames aFileNames(aRepresentationKey.begin(), aRepresentationKey.end());
+
+  aRepresentationKey.insert( theMeshName );
+  aRepresentationKey.insert( theFieldName );
+
+  TRepresentation2Input::iterator anIter = myRepresentation2Input.find(aRepresentationKey);
+  if(anIter == myRepresentation2Input.end()){
+    std::string aFileName = SALOMEDS_Tool::GetTmpDir() + "tmp.med";
+    //cout<<"MultiResult_i::GetInput - '"<<aFileName<<"'"<<endl;
+    int aRes = multipr::merge(aFileNames, theMeshName.c_str(), theFieldName.c_str(), aFileName.c_str());
+    if (aRes == 0) {
+      QFile(aFileName.c_str()).remove();
+      throw std::runtime_error("empty mesh"); 
+    }
+    PInput anInput(CreateConvertor(aFileName));
+    anInput->Build();
+    myRepresentation2Input[aRepresentationKey] = anInput;
+    return anInput;
+  }
+  
+  return anIter->second;
+}
+
+
+#endif // ENABLE_MULTIPR
diff --git a/src/VISU_I/VISU_MultiResult_i.hh b/src/VISU_I/VISU_MultiResult_i.hh
new file mode 100644 (file)
index 0000000..b05dd5f
--- /dev/null
@@ -0,0 +1,125 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//  File   : VISU_MultiResult_i.hh
+//  Author : Alexey PETROV
+//  Module : VISU
+
+#ifndef __VISU_MULTI_RESULT_I_H__
+#define __VISU_MULTI_RESULT_I_H__
+
+#ifndef ENABLE_MULTIPR
+#  define RESULT_CLASS_NAME Result_i
+#else
+#  define RESULT_CLASS_NAME MultiResult_i
+
+#include "VISU_Result_i.hh"
+
+#include <set>
+
+namespace VISU
+{
+  //----------------------------------------------------------------------------
+  class MultiResult_i : public virtual Result_i
+  {
+    MultiResult_i(const MultiResult_i&);
+
+  public:
+    typedef Result_i TSuperClass;
+
+    MultiResult_i(SALOMEDS::Study_ptr theStudy,
+                 const ESourceId& theSourceId,
+                 const ECreationId& theCreationId,
+                 CORBA::Boolean theIsBuildImmediately = true,
+                 CORBA::Boolean theIsBuildFields = true,
+                 CORBA::Boolean theIsBuildMinMax = true,
+                 CORBA::Boolean theIsBuildGroups = true);
+
+    virtual
+    ~MultiResult_i();
+
+    virtual
+    CORBA::Boolean
+    IsDone();
+
+    typedef std::string TPartName;
+    typedef std::string TFileName;
+    typedef std::map<TPartName, TFileName> TPartName2FileName;
+    typedef std::map<TPartName, TResolutionID> TPartName2ResolutionID;
+
+    typedef std::set<std::string> TRepresentationKey;
+    typedef std::map<TRepresentationKey, PInput> TRepresentation2Input;
+
+  private:
+    QFileInfo myMPFileInfo;
+    TPartName2FileName myPartName2FileName;
+    TPartName2ResolutionID myPartName2ResolutionID;
+
+    TRepresentation2Input myRepresentation2Input;
+
+  protected:
+    virtual
+    Storable* 
+    Build(SALOMEDS::SObject_ptr theSObject,
+         CORBA::Boolean theIsAtOnce = true) ;
+
+    virtual
+    void
+    BuildDataTree(const std::string& theResultEntry);
+
+  public:
+    virtual 
+    size_t
+    IsPossible();
+
+    virtual
+    Storable* 
+    Create(const char* theFileName);
+
+    virtual 
+    Storable*
+    Restore(SALOMEDS::SObject_ptr theSObject,
+           const Storable::TRestoringMap& theMap,
+           const std::string& thePrefix);
+
+    virtual
+    void
+    ToStream(std::ostringstream& theStr);
+
+    virtual
+    PInput
+    GetInput(const std::string& theMeshName = "",
+            VISU::Entity theEntity = VISU::NONE,
+            const std::string& theFieldName = "", 
+            CORBA::Long theTimeStampNumber = -1);
+
+    virtual
+    void
+    SetResolution(const std::string& theName, 
+                 TResolutionID theNewResolution); // 'F'=FULL  'M'=MEDIUM  'L'=LOW  'H'=HIDE 
+  };
+
+}
+
+#endif // ENABLE_MULTIPR
+
+#endif // __VISU_MULTI_RESULT_I_H__
diff --git a/src/VISU_I/VISU_ResultUtils.cc b/src/VISU_I/VISU_ResultUtils.cc
new file mode 100644 (file)
index 0000000..82bcfdc
--- /dev/null
@@ -0,0 +1,605 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//  File   : VISU_ResultUtils.cc
+//  Author : Alexey PETROV
+//  Module : VISU
+
+#include "VISU_ResultUtils.hh"
+
+#include "SUIT_Session.h"
+#include "SALOME_Event.hxx"
+#include "SalomeApp_Study.h"
+#include "SalomeApp_Application.h"
+
+#include "VISU_Convertor.hxx"
+#include "VISU_ConvertorUtils.hxx"
+
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#ifdef _DEBUG_
+static int MYTIMEDEBUG = 0;
+#else
+static int MYTIMEDEBUG = 0;
+#endif
+
+namespace VISU
+{
+  //----------------------------------------------------------------------------
+  typedef boost::recursive_mutex TMutex;
+  typedef TMutex::scoped_lock TLock;
+
+  static TMutex myMutex;
+
+
+  //----------------------------------------------------------------------------
+  TUpdateObjBrowser
+  ::TUpdateObjBrowser(const int theStudyId, CORBA::Boolean* theIsDone):
+    myStudyId(theStudyId),
+    myIsDone(theIsDone)
+  {}
+    
+  
+  //----------------------------------------------------------------------------
+  void
+  TUpdateObjBrowser
+  ::Execute()
+  {
+    TLock aLock(myMutex);
+    SUIT_Session* aSession = SUIT_Session::session();
+    QPtrList<SUIT_Application> anApplications = aSession->applications();
+    QPtrListIterator<SUIT_Application> anIter (anApplications);
+    while (SUIT_Application* aSApp = anIter.current()) {
+      if(SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSApp)){
+       if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy())) {
+         if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+           if (myStudyId == aCStudy->StudyId()) {
+             TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::updateObjectBrowser");
+             anApp->updateObjectBrowser();
+             *myIsDone = true;
+             break;
+           }
+         }
+       }
+      }
+      ++anIter;
+    }
+  }
+
+
+  //----------------------------------------------------------------------------
+  struct TResultManager
+  {
+    Result_i* myResult;
+
+    TResultManager(Result_i* theResult):
+      myResult(theResult)
+    {
+      myResult->Register();
+    }
+
+    ~TResultManager()
+    {
+      myResult->Destroy();
+    }
+  };
+
+
+  //----------------------------------------------------------------------------
+  struct TTransactionManager
+  {
+    _PTR(StudyBuilder) myStudyBuilder;
+
+    TTransactionManager(_PTR(Study) theStudyDocument):
+      myStudyBuilder(theStudyDocument->NewBuilder())
+    {
+      TLock aLock(myMutex);
+      myStudyBuilder->NewCommand();
+    }
+
+    ~TTransactionManager()
+    {
+      TLock aLock(myMutex);
+      myStudyBuilder->CommitCommand();
+    }
+  };
+
+
+  //----------------------------------------------------------------------------
+  QString
+  GenerateName(const std::string& theName)
+  {
+    TLock aLock(myMutex);
+
+    typedef std::map<std::string, int> TNameMap;
+    static TNameMap aMap;
+
+    TNameMap::const_iterator anIter = aMap.find(theName);
+    QString aResult;
+    if (anIter == aMap.end()) {
+      aMap[theName] = 0;
+      aResult = theName;
+    } else {
+      aResult = GenerateName(theName,++aMap[theName]);
+    }
+    return aResult;
+  }
+  
+
+  //----------------------------------------------------------------------------
+  QString 
+  GenerateFieldName (const string& theName, const string& theUnits)
+  {
+    QString aName;
+    const string tmp (theUnits.size(),' ');
+    if (theUnits == "" || theUnits == tmp)
+      aName.sprintf("%s, -",theName.c_str());
+    else
+      aName.sprintf("%s, %s",theName.c_str(),theUnits.c_str());
+    aName = aName.simplifyWhiteSpace();
+    return aName.latin1();
+  }
+
+
+  //----------------------------------------------------------------------------
+  void
+  CreateReference(_PTR(Study) theStudyDocument,
+                 const string& theFatherEntry, 
+                 const string& theRefEntry)
+  {
+    _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
+    _PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry);
+    _PTR(SObject) aNewObj = aStudyBuilder->NewObject(aFather);
+    _PTR(SObject) aRefSObj = theStudyDocument->FindObjectID(theRefEntry);
+    aStudyBuilder->Addreference(aNewObj,aRefSObj);
+  }
+
+
+  //----------------------------------------------------------------------------
+  void 
+  RemoveSObject(_PTR(Study) theStudyDocument,
+               const string& theEntry)
+  {
+    _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
+    _PTR(SObject) aSObject = theStudyDocument->FindObjectID(theEntry);
+    aStudyBuilder->RemoveObject(aSObject);
+  }
+
+
+  //----------------------------------------------------------------------------
+  void
+  BuildEntities(Result_i* theResult,
+               Result_i::PInput theInput,
+               CORBA::Boolean* theIsDone,
+               const std::string& theResultEntry,
+               CORBA::Boolean theIsAtOnce,
+               CORBA::Boolean theIsBuildGroups,
+               CORBA::Boolean theIsBuildFields,
+               CORBA::Boolean theIsBuildParts,
+               _PTR(Study) theStudy)
+  {
+    if(*theIsDone)
+      return;
+
+    TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildEntities");
+    TResultManager aResultManager(theResult);
+    TTransactionManager aTransactionManager(theStudy);
+
+    {
+      TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildEntities");
+      theInput->BuildEntities();
+    }
+
+    QString aComment,aTmp;
+    const TMeshMap& aMeshMap = theInput->GetMeshMap();
+    TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
+    for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
+      const string& aMeshName = aMeshMapIter->first;
+      const PMesh& aMesh = aMeshMapIter->second;
+      const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+      if(aMeshOnEntityMap.empty()) 
+       continue;
+      aComment.sprintf("myComment=MESH;myName=%s;myDim=%d",
+                      aMeshName.c_str(),
+                      aMesh->myDim);
+      aMesh->myEntry = 
+       CreateAttributes(theStudy,
+                        theResultEntry,
+                        NO_ICON,
+                        NO_IOR,
+                        aMeshName,
+                        NO_PERFSITENT_REF,
+                        aComment.latin1(),
+                        true);
+    
+      aComment.sprintf("myComment=FAMILIES;myMeshName=%s",
+                      aMeshName.c_str());
+      std::string aSubMeshesEntry = 
+       CreateAttributes(theStudy,
+                        aMesh->myEntry,
+                        NO_ICON,
+                        NO_IOR,
+                        "Families",
+                        NO_PERFSITENT_REF,
+                        aComment.latin1(),
+                        true);
+
+      if(theIsBuildGroups){
+       aMesh->myGroupsEntry =
+         CreateAttributes(theStudy,
+                          aMesh->myEntry,
+                          NO_ICON,
+                          NO_IOR,
+                          NO_NAME,
+                          NO_PERFSITENT_REF,
+                          NO_COMMENT,
+                          true);
+      }
+       
+      if(theIsBuildFields){
+       aMesh->myFieldsEntry =
+         CreateAttributes(theStudy,
+                          aMesh->myEntry,
+                          NO_ICON,
+                          NO_IOR,
+                          NO_NAME,
+                          NO_PERFSITENT_REF,
+                          NO_COMMENT,
+                          true);
+      }
+
+      if(theIsBuildParts){
+       aMesh->myPartsEntry =
+         CreateAttributes(theStudy,
+                          aMesh->myEntry,
+                          NO_ICON,
+                          NO_IOR,
+                          NO_NAME,
+                          NO_PERFSITENT_REF,
+                          NO_COMMENT,
+                          true);
+      }
+
+      //Import entities
+      TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
+      for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
+       const TEntity& anEntity = aMeshOnEntityMapIter->first;
+       const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
+       
+       string anEntityName;
+       switch(anEntity){
+       case NODE_ENTITY: 
+         anEntityName = "onNodes"; 
+         break;
+       case EDGE_ENTITY: 
+         anEntityName = "onEdges"; 
+         break;
+       case FACE_ENTITY: 
+         anEntityName = "onFaces"; 
+         break;
+       case CELL_ENTITY: 
+         anEntityName = "onCells"; 
+         break;
+       default:
+       continue;
+       }
+       
+       aComment.sprintf("myComment=ENTITY;myMeshName=%s;myId=%d",
+                        aMeshName.c_str(),
+                        anEntity);
+       
+       aMeshOnEntity->myEntry = 
+         CreateAttributes(theStudy, 
+                          aSubMeshesEntry, 
+                          NO_ICON,
+                          NO_IOR,
+                          anEntityName.c_str(),
+                          NO_PERFSITENT_REF,
+                          aComment.latin1(), 
+                          true);
+      }
+    }
+    
+    ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
+  }
+
+
+  //----------------------------------------------------------------------------
+  void
+  BuildGroups(Result_i* theResult,
+             Result_i::PInput theInput,
+             CORBA::Boolean* theIsDone,
+             CORBA::Boolean theIsBuild,
+             CORBA::Boolean theIsAtOnce,
+             _PTR(Study) theStudy)
+  {
+    if(!theIsBuild || *theIsDone)
+      return;
+
+    TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildGroups");
+    TResultManager aResultManager(theResult);
+    TTransactionManager aTransactionManager(theStudy);
+    
+    {
+      TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildGroups");
+      theInput->BuildGroups();
+    }
+
+    QString aComment,aTmp;
+    const TMeshMap& aMeshMap = theInput->GetMeshMap();
+    TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
+    for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
+      const string& aMeshName = aMeshMapIter->first;
+      const PMesh& aMesh = aMeshMapIter->second;
+      
+      const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+      if(aMeshOnEntityMap.empty()) 
+       continue;
+      
+      TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
+      for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
+       const TEntity& anEntity = aMeshOnEntityMapIter->first;
+       const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
+       
+       const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
+       TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
+       for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
+         const string& aFamilyName = aFamilyMapIter->first;
+         const PFamily& aFamily = aFamilyMapIter->second;
+         aComment.sprintf("myComment=FAMILY;myMeshName=%s;myEntityId=%d;myName=%s",
+                          aMeshName.c_str(),
+                          anEntity,
+                          aFamilyName.c_str());
+         
+         aFamily->myEntry =
+           CreateAttributes(theStudy,
+                            aMeshOnEntity->myEntry,
+                            NO_ICON,
+                            NO_IOR,
+                            aFamilyName,
+                            NO_PERFSITENT_REF,
+                            aComment.latin1(),
+                            true);
+       }
+      }
+      //Importing groups
+      const TGroupMap& aGroupMap = aMesh->myGroupMap;
+      if(!aGroupMap.empty()){
+       aComment.sprintf("myComment=GROUPS;myMeshName=%s",
+                        aMeshName.c_str());
+       
+       CreateAttributes(theStudy,
+                        aMesh->myGroupsEntry,
+                        NO_ICON,
+                        NO_IOR,
+                        "Groups",
+                        NO_PERFSITENT_REF,
+                        aComment.latin1(),
+                        false);
+
+       TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
+       for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
+         const string& aGroupName = aGroupMapIter->first;
+         const PGroup& aGroup = aGroupMapIter->second;
+         aComment.sprintf("myComment=GROUP;myMeshName=%s;myName=%s",
+                          aMeshName.c_str(),
+                          aGroupName.c_str());
+         aGroup->myEntry = 
+           CreateAttributes(theStudy,
+                            aMesh->myGroupsEntry,
+                            NO_ICON,
+                            NO_IOR,
+                            aGroupName,
+                            NO_PERFSITENT_REF,
+                            aComment.latin1(),
+                            true);
+         const TFamilySet& aFamilySet = aGroup->myFamilySet;
+         TFamilySet::const_iterator aFamilyIter = aFamilySet.begin();
+         for(; aFamilyIter != aFamilySet.end(); aFamilyIter++){
+           const PFamily& aFamily = *aFamilyIter;
+           CreateReference(theStudy,
+                           aGroup->myEntry,
+                           aFamily->myEntry);
+         }
+       }
+      }else if(!theIsAtOnce)
+       RemoveSObject(theStudy,
+                     aMesh->myGroupsEntry);
+    }
+    
+    ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
+  }
+
+
+  //----------------------------------------------------------------------------
+  void
+  BuildFields(Result_i* theResult,
+             Result_i::PInput theInput,
+             CORBA::Boolean* theIsDone,
+             CORBA::Boolean theIsBuild,
+             CORBA::Boolean theIsAtOnce,
+             _PTR(Study) theStudy)
+  {
+    if(!theIsBuild || *theIsDone)
+      return;
+
+    TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildFields");
+    TResultManager aResultManager(theResult);
+    TTransactionManager aTransactionManager(theStudy);
+
+    {
+      TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildFields");
+      theInput->BuildFields();
+    }
+
+    QString aComment,aTmp;
+    const TMeshMap& aMeshMap = theInput->GetMeshMap();
+    TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
+
+    for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++)
+    {
+      const string& aMeshName = aMeshMapIter->first;
+      const PMesh& aMesh = aMeshMapIter->second;
+
+      const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+      if(aMeshOnEntityMap.empty()) 
+       continue;
+
+      //Import fields
+      bool anIsFieldsEntryUpdated = false;
+      TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
+
+      for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++)
+      {
+       const TEntity& anEntity = aMeshOnEntityMapIter->first;
+       const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
+       const TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+       TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
+
+       for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++)
+       {
+         if(!anIsFieldsEntryUpdated)
+         {
+           aComment = "";
+           aComment.append("myComment=FIELDS;");
+           aComment.append("myMeshName=");aComment.append(aMeshName);
+
+           CreateAttributes(theStudy,
+                            aMesh->myFieldsEntry,
+                            NO_ICON,
+                            NO_IOR,
+                            "Fields",
+                            NO_PERFSITENT_REF,
+                            aComment.latin1(),
+                            false);
+
+           anIsFieldsEntryUpdated = true;
+         }
+
+         const string& aFieldName = aFieldMapIter->first;
+         const PField& aField = aFieldMapIter->second;
+         const TValField& aValField = aField->myValField;
+         QString aFieldNameWithUnit = GenerateFieldName(aFieldName,aField->myUnitNames[0]);
+         aComment.sprintf("myComment=FIELD;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d",
+                          aMeshName.c_str(),
+                          anEntity,
+                          aFieldName.c_str(),
+                          aValField.size(),
+                          aField->myNbComp);
+         
+         aField->myEntry = CreateAttributes(theStudy,
+                                            aMesh->myFieldsEntry,
+                                            NO_ICON,
+                                            NO_IOR,
+                                            aFieldNameWithUnit.latin1(),
+                                            NO_PERFSITENT_REF,
+                                            aComment.latin1(),
+                                            true);
+
+         CreateReference(theStudy,
+                         aField->myEntry,
+                         aMeshOnEntity->myEntry);
+
+         TValField::const_iterator aValFieldIter = aValField.begin();
+
+         for(; aValFieldIter != aValField.end(); aValFieldIter++)
+         {
+           int aTimeStamp = aValFieldIter->first;
+           const PValForTime& aValForTime = aValFieldIter->second;
+           aComment.sprintf("myComment=TIMESTAMP;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
+                            aMeshName.c_str(),
+                            anEntity,
+                            aFieldName.c_str(),
+                            aTimeStamp,
+                            aField->myNbComp);
+
+           string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime);
+
+           aValForTime->myEntry = CreateAttributes(theStudy,
+                                                   aField->myEntry,
+                                                   NO_ICON,
+                                                   NO_IOR,
+                                                   aTimeStampId,
+                                                   NO_PERFSITENT_REF,
+                                                   aComment.latin1(),
+                                                   true);
+         }
+       }
+      }
+
+      if(!anIsFieldsEntryUpdated && !theIsAtOnce)
+       RemoveSObject(theStudy, aMesh->myFieldsEntry);
+    }
+
+    ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
+  }
+
+
+  //----------------------------------------------------------------------------
+  void
+  BuildMinMax(Result_i* theResult,
+             Result_i::PInput theInput,
+             CORBA::Boolean* theIsDone,
+             CORBA::Boolean theIsBuild)
+  {
+    if(!theIsBuild || *theIsDone)
+      return;
+
+    TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildMinMax");
+    TResultManager aResultManager(theResult);
+    
+    theInput->BuildMinMax();
+
+    *theIsDone = true;
+
+    theResult->UpdateObservers();
+  }
+
+
+  //----------------------------------------------------------------------------
+  void
+  BuildFieldDataTree(Result_i* theResult,
+                    Result_i::PInput theInput,
+                    CORBA::Boolean* theIsFieldsDone,
+                    CORBA::Boolean theIsBuildFields,
+                    CORBA::Boolean* theIsMinMaxDone,
+                    CORBA::Boolean theIsBuildMinMax,
+                    _PTR(Study) theStudy)
+  {
+    BuildFields(theResult,
+               theInput,
+               theIsFieldsDone,
+               theIsBuildFields,
+               false,
+               theStudy);
+
+    BuildMinMax(theResult,
+               theInput,
+               theIsMinMaxDone,
+               theIsBuildMinMax);
+  }
+
+
+  //----------------------------------------------------------------------------
+}
diff --git a/src/VISU_I/VISU_ResultUtils.hh b/src/VISU_I/VISU_ResultUtils.hh
new file mode 100644 (file)
index 0000000..2c9b0aa
--- /dev/null
@@ -0,0 +1,110 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//  File   : VISU_ResultUtils.hh
+//  Author : Alexey PETROV
+//  Module : VISU
+
+#ifndef __VISU_RESULT_UTILS_H__
+#define __VISU_RESULT_UTILS_H__
+
+#include "VISU_Result_i.hh"
+#include "SALOME_Event.hxx"
+
+#include <set>
+
+namespace VISU
+{
+  //----------------------------------------------------------------------------
+  struct TUpdateObjBrowser: public SALOME_Event
+  {
+    int myStudyId;
+    CORBA::Boolean* myIsDone;
+    TUpdateObjBrowser(const int theStudyId, CORBA::Boolean* theIsDone);
+
+    virtual
+    void
+    Execute();
+  };
+
+
+  //----------------------------------------------------------------------------
+  QString
+  GenerateName(const std::string& theName);
+
+
+  //----------------------------------------------------------------------------
+  void
+  BuildEntities(Result_i* theResult,
+               Result_i::PInput theInput,
+               CORBA::Boolean* theIsDone,
+               const std::string& theResultEntry,
+               CORBA::Boolean theIsAtOnce,
+               CORBA::Boolean theIsBuildGroups,
+               CORBA::Boolean theIsBuildFields,
+               CORBA::Boolean theIsBuildParts,
+               _PTR(Study) theStudy);
+
+  
+  //----------------------------------------------------------------------------
+  void
+  BuildGroups(Result_i* theResult,
+             Result_i::PInput theInput,
+             CORBA::Boolean* theIsDone,
+             CORBA::Boolean theIsBuild,
+             CORBA::Boolean theIsAtOnce,
+             _PTR(Study) theStudy);
+
+  
+  //----------------------------------------------------------------------------
+  void
+  BuildFields(Result_i* theResult,
+             Result_i::PInput theInput,
+             CORBA::Boolean* theIsDone,
+             CORBA::Boolean theIsBuild,
+             CORBA::Boolean theIsAtOnce,
+             _PTR(Study) theStudy);
+
+  
+  //----------------------------------------------------------------------------
+  void
+  BuildMinMax(Result_i* theResult,
+             Result_i::PInput theInput,
+             CORBA::Boolean* theIsDone,
+             CORBA::Boolean theIsBuild);
+
+
+  //----------------------------------------------------------------------------
+  void
+  BuildFieldDataTree(Result_i* theResult,
+                    Result_i::PInput theInput,
+                    CORBA::Boolean* theIsFieldsDone,
+                    CORBA::Boolean theIsBuildFields,
+                    CORBA::Boolean* theIsMinMaxDone,
+                    CORBA::Boolean theIsBuildMinMax,
+                    _PTR(Study) theStudy);
+
+  //----------------------------------------------------------------------------
+}
+
+
+#endif // __VISU_RESULT_UTILS_H__
index 162842b96d4f44189266d565a6d1776215fc5f46..1b3bf77cdef26808e63bb339b0af47ebc8083aa5 100644 (file)
@@ -24,7 +24,8 @@
 //  Author : Alexey PETROV
 //  Module : VISU
 
-#include "VISU_Result_i.hh"
+#include "VISU_MultiResult_i.hh"
+#include "VISU_ResultUtils.hh"
 
 #include "VISU_Convertor_impl.hxx"
 #include "VISU_CorbaMedConvertor.hxx"
 #include "SalomeApp_Study.h"
 #include "SalomeApp_Application.h"
 
-#include <boost/thread/recursive_mutex.hpp>
 #include <boost/thread/thread.hpp>
-
-#include <boost/thread/mutex.hpp>
 #include <boost/bind.hpp>
 
 // QT Includes
 // OCCT Includes
 #include <Bnd_Box.hxx>
 
-#ifdef ENABLE_MULTIPR
-// MULTIPR
-#include "MULTIPR_Obj.hxx"
-#endif
-
-using namespace VISU;
-using namespace std;
 
 #ifdef _DEBUG_
 static int MYDEBUG = 1;
-static int MYTIMEDEBUG = 0;
 #else
 static int MYDEBUG = 0;
-static int MYTIMEDEBUG = 0;
 #endif
 
 
@@ -82,7 +71,7 @@ namespace VISU
 {
   //---------------------------------------------------------------
   Result_var 
-  FindResult (SALOMEDS::SObject_ptr theSObject)
+  FindResult(SALOMEDS::SObject_ptr theSObject)
   {
     SALOMEDS::SComponent_var aSComponent = theSObject->GetFatherComponent();
     SALOMEDS::SObject_var aFather = theSObject->GetFather();
@@ -117,85 +106,7 @@ namespace VISU
 
 
   //---------------------------------------------------------------
-  typedef boost::recursive_mutex TMutex;
-  typedef TMutex::scoped_lock TLock;
-
-  static TMutex myMutex;
-
-  //---------------------------------------------------------------
-  struct TGetStudy: public SALOME_Event
-  {
-    typedef _PTR(Study) TResult;
-    TResult myResult;
-    int myStudyId;
-
-    TGetStudy(const int theStudyId):
-      myStudyId(theStudyId)
-    {}
-    
-    virtual
-    void
-    Execute()
-    {
-      SUIT_Session* aSession = SUIT_Session::session();
-      QPtrList<SUIT_Application> anApplications = aSession->applications();
-      QPtrListIterator<SUIT_Application> anIter (anApplications);
-      while (SUIT_Application* aSApp = anIter.current()) {
-       if(SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSApp)){
-         if(SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy())) {
-           if(_PTR(Study) aStudyDS = aStudy->studyDS()){
-             if(aStudyDS->StudyId() == myStudyId){
-               myResult = aStudy->studyDS();
-               break;
-             }
-           }
-         }
-       }
-       ++anIter;
-      }
-    }
-  };
-
-
-  //---------------------------------------------------------------
-  QString
-  GenerateName (const std::string& theName)
-  {
-    TLock aLock(myMutex);
-
-    typedef map<string,int> TNameMap;
-    static TNameMap aMap;
-
-    TNameMap::const_iterator i = aMap.find(theName);
-    QString tmp;
-    if (i == aMap.end()) {
-      aMap[theName] = 0;
-      tmp = theName;
-    } else {
-      tmp = GenerateName(theName,++aMap[theName]);
-    }
-    if(MYDEBUG) MESSAGE("GenerateName - "<<tmp<<" from - "<<theName<<"; " <<aMap[theName]);
-    return tmp;
-  }
-  
-
-  //---------------------------------------------------------------
-  QString 
-  GenerateFieldName (const string& theName, const string& theUnits)
-  {
-    QString aName;
-    const string tmp (theUnits.size(),' ');
-    if (theUnits == "" || theUnits == tmp)
-      aName.sprintf("%s, -",theName.c_str());
-    else
-      aName.sprintf("%s, %s",theName.c_str(),theUnits.c_str());
-    aName = aName.simplifyWhiteSpace();
-    return aName.latin1();
-  }
-
-
-  //---------------------------------------------------------------
-  string
+  std::string
   GetComponentDataType (SALOMEDS::SObject_ptr theSObject)
   {
     SALOMEDS::SComponent_var aCompRefSObj = theSObject->GetFatherComponent();
@@ -218,858 +129,7 @@ namespace VISU
   }
 
 
-  //---------------------------------------------------------------
-  void
-  CreateReference (_PTR(Study) theStudyDocument,
-                  const string& theFatherEntry, 
-                  const string& theRefEntry)
-  {
-    TLock aLock(myMutex);
-
-    _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
-    _PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry);
-    _PTR(SObject) aNewObj = aStudyBuilder->NewObject(aFather);
-    _PTR(SObject) aRefSObj = theStudyDocument->FindObjectID(theRefEntry);
-    aStudyBuilder->Addreference(aNewObj,aRefSObj);
-  }
-
-
-  //---------------------------------------------------------------
-  inline
-  std::string 
-  CreateAttributes(_PTR(Study) theStudyDocument,
-                  const string& theFatherEntry, 
-                  const string& theIOR, 
-                  const string& theName,
-                  const string& theComment,
-                  CORBA::Boolean theCreateNew,
-                  const string& theIcon = "")
-  {
-    TLock aLock(myMutex);
-
-    _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
-    _PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry);
-
-    _PTR(SObject) aNewObj;
-    if(theCreateNew)
-      aNewObj = aStudyBuilder->NewObject(aFather);
-    else
-      aNewObj = aFather;
-
-    _PTR(GenericAttribute) anAttr;
-    if (theIOR != "") {
-      anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeIOR");
-      _PTR(AttributeIOR) anIOR (anAttr);
-      anIOR->SetValue(theIOR);
-    }
-    if (theName != "") {
-      anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeName");
-      _PTR(AttributeName) aName (anAttr);
-      aName->SetValue(theName);
-    }
-    if (theComment != "") {
-      anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeString");
-      _PTR(AttributeString) aCmnt (anAttr);
-      aCmnt->SetValue(theComment);
-    }
-    // MULTIPR
-    if (theIcon != "") {
-      anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributePixMap");
-      _PTR(AttributePixMap) aPixmap (anAttr);
-      aPixmap->SetPixMap(theIcon.c_str());
-    }
-    return aNewObj->GetID();
-  }
-
-
-  //---------------------------------------------------------------
-  inline
-  void 
-  UpdateAttributes(_PTR(Study) theStudyDocument,
-                  const string& theEntry,
-                  const string& theIOR, 
-                  const string& theName,
-                  const string& theComment)
-  {
-    TLock aLock(myMutex);
-
-    _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
-    _PTR(SObject) aSObject = theStudyDocument->FindObjectID(theEntry);
-
-    _PTR(GenericAttribute) anAttr;
-    if (theIOR != "") {
-      anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeIOR");
-      _PTR(AttributeIOR) anIOR (anAttr);
-      anIOR->SetValue(theIOR);
-    }
-    if (theName != "") {
-      anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeName");
-      _PTR(AttributeName) aName (anAttr);
-      aName->SetValue(theName);
-    }
-    if (theComment != "") {
-      anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeString");
-      _PTR(AttributeString) aCmnt (anAttr);
-      aCmnt->SetValue(theComment);
-    }
-  }
-
-
-  //---------------------------------------------------------------
-  inline
-  void 
-  RemoveSObject(_PTR(Study) theStudyDocument,
-                  const string& theEntry)
-  {
-    TLock aLock(myMutex);
-
-    _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
-    _PTR(SObject) aSObject = theStudyDocument->FindObjectID(theEntry);
-    aStudyBuilder->RemoveObject(aSObject);
-  }
-
-
-  //---------------------------------------------------------------
-  struct TResultManager
-  {
-    Result_i* myResult;
-
-    TResultManager(Result_i* theResult):
-      myResult(theResult)
-    {
-      myResult->Register();
-    }
-
-    ~TResultManager()
-    {
-      myResult->Destroy();
-    }
-  };
-
-
-  //---------------------------------------------------------------
-  struct TTransactionManager
-  {
-    _PTR(StudyBuilder) myStudyBuilder;
-
-    TTransactionManager(_PTR(Study) theStudyDocument):
-      myStudyBuilder(theStudyDocument->NewBuilder())
-    {
-      TLock aLock(myMutex);
-      myStudyBuilder->NewCommand();
-    }
-
-    ~TTransactionManager()
-    {
-      TLock aLock(myMutex);
-      myStudyBuilder->CommitCommand();
-    }
-  };
-
-
-  //---------------------------------------------------------------
-  struct TUpdateObjBrowser: public SALOME_Event
-  {
-    int myStudyId;
-    CORBA::Boolean* myIsDone;
-    TUpdateObjBrowser(const int theStudyId,
-                     CORBA::Boolean* theIsDone):
-      myStudyId(theStudyId),
-      myIsDone(theIsDone)
-    {}
-    
-    virtual
-    void
-    Execute()
-    {
-      TLock aLock(myMutex);
-      SUIT_Session* aSession = SUIT_Session::session();
-      QPtrList<SUIT_Application> anApplications = aSession->applications();
-      QPtrListIterator<SUIT_Application> anIter (anApplications);
-      while (SUIT_Application* aSApp = anIter.current()) {
-       if(SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSApp)){
-         if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy())) {
-           if (_PTR(Study) aCStudy = aStudy->studyDS()) {
-             if (myStudyId == aCStudy->StudyId()) {
-               TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::updateObjectBrowser");
-               anApp->updateObjectBrowser();
-               *myIsDone = true;
-               break;
-             }
-           }
-         }
-       }
-       ++anIter;
-      }
-    }
-  };
-
-
-  //---------------------------------------------------------------
-  void
-  BuildEntities(Result_i* theResult,
-               VISU_Convertor* theInput,
-               CORBA::Boolean* theIsDone,
-               std::string theResultEntry,
-               CORBA::Boolean theIsAtOnce,
-               CORBA::Boolean theIsBuildGroups,
-               CORBA::Boolean theIsBuildFields,
-               _PTR(Study) theStudy)
-  {
-    if(*theIsDone)
-      return;
-
-    TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildEntities");
-    TResultManager aResultManager(theResult);
-    TTransactionManager aTransactionManager(theStudy);
-
-    {
-      TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildEntities");
-      theInput->BuildEntities();
-    }
-
-    QString aComment,aTmp;
-    const TMeshMap& aMeshMap = theInput->GetMeshMap();
-    TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
-    for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
-      const string& aMeshName = aMeshMapIter->first;
-      const PMesh& aMesh = aMeshMapIter->second;
-      const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
-      if(aMeshOnEntityMap.empty()) 
-       continue;
-      aComment.sprintf("myComment=MESH;myName=%s;myDim=%d",
-                      aMeshName.c_str(),
-                      aMesh->myDim);
-      aMesh->myEntry = 
-       CreateAttributes(theStudy,
-                        theResultEntry,
-                        "",
-                        aMeshName,
-                        aComment.latin1(),
-                        true);
-    
-      aComment.sprintf("myComment=FAMILIES;myMeshName=%s",
-                      aMeshName.c_str());
-      string aSubMeshesEntry = 
-       CreateAttributes(theStudy,
-                        aMesh->myEntry,
-                        "",
-                        "Families",
-                        aComment.latin1(),
-                        true);
-
-      if(theIsBuildGroups){
-       aMesh->myGroupsEntry =
-         CreateAttributes(theStudy,
-                          aMesh->myEntry,
-                          "",
-                          "",
-                          "",
-                          true);
-      }
-       
-      if(theIsBuildFields){
-       aMesh->myFieldsEntry =
-         CreateAttributes(theStudy,
-                          aMesh->myEntry,
-                          "",
-                          "",
-                          "",
-                          true);
-      }
-
-#ifdef ENABLE_MULTIPR
-      // MULTIPR
-      aMesh->myPartsEntry =
-       CreateAttributes(theStudy,
-                        aMesh->myEntry,
-                        "",
-                        "",
-                        "",
-                        true);
-#endif
-
-      //Import entities
-      TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
-      for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
-       const TEntity& anEntity = aMeshOnEntityMapIter->first;
-       const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
-       
-       string anEntityName;
-       switch(anEntity){
-       case NODE_ENTITY: 
-         anEntityName = "onNodes"; 
-         break;
-       case EDGE_ENTITY: 
-         anEntityName = "onEdges"; 
-         break;
-       case FACE_ENTITY: 
-         anEntityName = "onFaces"; 
-         break;
-       case CELL_ENTITY: 
-         anEntityName = "onCells"; 
-         break;
-       default:
-       continue;
-       }
-       
-       aComment.sprintf("myComment=ENTITY;myMeshName=%s;myId=%d",
-                        aMeshName.c_str(),
-                        anEntity);
-       
-       aMeshOnEntity->myEntry = 
-         CreateAttributes(theStudy, 
-                          aSubMeshesEntry, 
-                          "", 
-                          anEntityName.c_str(), 
-                          aComment.latin1(), 
-                          true);
-      }
-    }
-    
-    ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
-  }
-
-  //---------------------------------------------------------------
-  void
-  BuildGroups(Result_i* theResult,
-             VISU_Convertor* theInput,
-             CORBA::Boolean* theIsDone,
-             CORBA::Boolean theIsBuild,
-             CORBA::Boolean theIsAtOnce,
-             _PTR(Study) theStudy)
-  {
-    if(!theIsBuild || *theIsDone)
-      return;
-
-    TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildGroups");
-    TResultManager aResultManager(theResult);
-    TTransactionManager aTransactionManager(theStudy);
-    
-    {
-      TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildGroups");
-      theInput->BuildGroups();
-    }
-
-    QString aComment,aTmp;
-    const TMeshMap& aMeshMap = theInput->GetMeshMap();
-    TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
-    for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
-      const string& aMeshName = aMeshMapIter->first;
-      const PMesh& aMesh = aMeshMapIter->second;
-      
-      const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
-      if(aMeshOnEntityMap.empty()) 
-       continue;
-      
-      TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
-      for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
-       const TEntity& anEntity = aMeshOnEntityMapIter->first;
-       const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
-       
-       const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
-       TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
-       for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
-         const string& aFamilyName = aFamilyMapIter->first;
-         const PFamily& aFamily = aFamilyMapIter->second;
-         aComment.sprintf("myComment=FAMILY;myMeshName=%s;myEntityId=%d;myName=%s",
-                          aMeshName.c_str(),
-                          anEntity,
-                          aFamilyName.c_str());
-         
-         aFamily->myEntry =
-           CreateAttributes(theStudy,
-                            aMeshOnEntity->myEntry,
-                            "",
-                            aFamilyName,
-                            aComment.latin1(),
-                            true);
-       }
-      }
-      //Importing groups
-      const TGroupMap& aGroupMap = aMesh->myGroupMap;
-      if(!aGroupMap.empty()){
-       aComment.sprintf("myComment=GROUPS;myMeshName=%s",
-                        aMeshName.c_str());
-       
-       UpdateAttributes(theStudy,
-                        aMesh->myGroupsEntry,
-                        "",
-                        "Groups",
-                        aComment.latin1());
-
-       TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
-       for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
-         const string& aGroupName = aGroupMapIter->first;
-         const PGroup& aGroup = aGroupMapIter->second;
-         aComment.sprintf("myComment=GROUP;myMeshName=%s;myName=%s",
-                          aMeshName.c_str(),
-                          aGroupName.c_str());
-         aGroup->myEntry = 
-           CreateAttributes(theStudy,
-                            aMesh->myGroupsEntry,
-                            "",
-                            aGroupName,
-                            aComment.latin1(),
-                            true);
-         const TFamilySet& aFamilySet = aGroup->myFamilySet;
-         TFamilySet::const_iterator aFamilyIter = aFamilySet.begin();
-         for(; aFamilyIter != aFamilySet.end(); aFamilyIter++){
-           const PFamily& aFamily = *aFamilyIter;
-           CreateReference(theStudy,
-                           aGroup->myEntry,
-                           aFamily->myEntry);
-         }
-       }
-      }else if(!theIsAtOnce)
-       RemoveSObject(theStudy,
-                     aMesh->myGroupsEntry);
-    }
-    
-    ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
-  }
-
-
-  //---------------------------------------------------------------
-  void BuildFields(
-       Result_i* theResult,
-       VISU_Convertor* theInput,
-       CORBA::Boolean* theIsDone,
-       CORBA::Boolean theIsBuild,
-       CORBA::Boolean theIsAtOnce,
-       _PTR(Study) theStudy)
-  {
-    if(!theIsBuild || *theIsDone)
-      return;
-
-    TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildFields");
-    TResultManager aResultManager(theResult);
-    TTransactionManager aTransactionManager(theStudy);
-
-    {
-      TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildFields");
-      theInput->BuildFields();
-    }
-
-    QString aComment,aTmp;
-    const TMeshMap& aMeshMap = theInput->GetMeshMap();
-    TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
-
-    for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++)
-    {
-      const string& aMeshName = aMeshMapIter->first;
-      const PMesh& aMesh = aMeshMapIter->second;
-
-      const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
-      if(aMeshOnEntityMap.empty()) 
-       continue;
-
-      //Import fields
-      bool anIsFieldsEntryUpdated = false;
-      TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
-
-      for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++)
-      {
-       const TEntity& anEntity = aMeshOnEntityMapIter->first;
-       const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
-       const TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
-       TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
-
-       for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++)
-       {
-         if(!anIsFieldsEntryUpdated)
-         {
-           aComment = "";
-           aComment.append("myComment=FIELDS;");
-           aComment.append("myMeshName=");aComment.append(aMeshName);
-
-           UpdateAttributes(
-                            theStudy,
-                            aMesh->myFieldsEntry,
-                            "",
-                            "Fields",
-                            aComment.latin1());
-
-           anIsFieldsEntryUpdated = true;
-         }
-
-         const string& aFieldName = aFieldMapIter->first;
-         const PField& aField = aFieldMapIter->second;
-         const TValField& aValField = aField->myValField;
-         QString aFieldNameWithUnit = GenerateFieldName(aFieldName,aField->myUnitNames[0]);
-         aComment.sprintf("myComment=FIELD;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d",
-                          aMeshName.c_str(),
-                          anEntity,
-                          aFieldName.c_str(),
-                          aValField.size(),
-                          aField->myNbComp);
-         
-         aField->myEntry = CreateAttributes(
-                                            theStudy,
-                                            aMesh->myFieldsEntry,
-                                            "",
-                                            aFieldNameWithUnit.latin1(),
-                                            aComment.latin1(),
-                                            true);
-
-         CreateReference(
-                         theStudy,
-                         aField->myEntry,
-                         aMeshOnEntity->myEntry);
-
-         TValField::const_iterator aValFieldIter = aValField.begin();
-
-         for(; aValFieldIter != aValField.end(); aValFieldIter++)
-         {
-           int aTimeStamp = aValFieldIter->first;
-           const PValForTime& aValForTime = aValFieldIter->second;
-           aComment.sprintf("myComment=TIMESTAMP;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
-                            aMeshName.c_str(),
-                            anEntity,
-                            aFieldName.c_str(),
-                            aTimeStamp,
-                            aField->myNbComp);
-
-           string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime);
-
-           aValForTime->myEntry = CreateAttributes(
-                                                   theStudy,
-                                                   aField->myEntry,
-                                                   "",
-                                                   aTimeStampId,
-                                                   aComment.latin1(),
-                                                   true);
-         }
-       }
-      }
-
-      if(!anIsFieldsEntryUpdated && !theIsAtOnce)
-       RemoveSObject(theStudy, aMesh->myFieldsEntry);
-    }
-
-    ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
-  }
-
-
-#ifdef ENABLE_MULTIPR
-  // MULTIPR
-  void BuildParts (Result_i* theResult,
-                  VISU_Convertor* theInput,
-                  CORBA::Boolean* theIsDone,
-                  CORBA::Boolean theIsBuild,
-                  CORBA::Boolean theIsAtOnce,
-                  _PTR(Study) theStudy)
-  {
-    if(!theIsBuild || *theIsDone)
-      return;
-
-    // if MED file is not a distributed MED file (created with MULTIPR),
-    // then it is not necessary to build parts
-    if (theResult->GetFileInfoMultipr().filePath().isEmpty())
-      return;
-
-    try
-    {
-      multipr::Obj multiprObj;
-      multiprObj.create(theResult->GetFileInfoMultipr().filePath().latin1());
-      if (multiprObj.isValidDistributedMEDFile())
-      {
-       theResult->SetIsDistributedMEDMultipr(true);
-
-       const TMeshMap& aMeshMap = theInput->GetMeshMap();
-       TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
-       const PMesh& aMesh = aMeshMapIter->second;
-
-       vector<string> listParts = multiprObj.getParts();
-
-       QString aComment = "Sub-parts: #";
-       aComment += QString::number(listParts.size());
-
-       UpdateAttributes(
-                        theStudy,
-                        aMesh->myPartsEntry,
-                        "",
-                        "Parts",
-                        aComment.latin1());
-
-       string lastEntry;
-
-       for (unsigned i = 0 ; i < listParts.size() ; i++)
-       {
-         const char* strItem = listParts[i].c_str();
-         const char* strPartInfo = multiprObj.getPartInfo(strItem).c_str();
-
-         char   lMeshName[256];
-         int    lId;
-         char   lPartName[256];
-         char   lPath[256];
-         char   lMEDFileName[256];
-
-         // parse infos
-         sscanf(strPartInfo, "%s %d %s %s %s", 
-                lMeshName,
-                &lId,
-                lPartName,
-                lPath,
-                lMEDFileName);
-
-         if ((strstr(lPartName,"_MED") != NULL) || (strstr(lPartName,"_LOW") != NULL))
-         {
-           QString aComment = "";
-           aComment.append("myComment=PART;"); 
-           aComment.append("res=ML;");
-           aComment.append("file=");
-           aComment.append(lMEDFileName);
-
-           CreateAttributes(
-                            theStudy,
-                            lastEntry, // father
-                            "",
-                            lPartName,
-                            aComment.latin1(),
-                            true);
-         }
-         else
-         {
-           QString aComment = "";
-           QString icon = "";
-
-           if (i != listParts.size()-1)
-           {
-             const char* strItemNext = listParts[i+1].c_str();
-             const char* strPartInfoNext = multiprObj.getPartInfo(strItemNext).c_str();
-             if ((strstr(strPartInfoNext,"_MED") != NULL) || (strstr(strPartInfoNext,"_LOW") != NULL))
-             {
-               // next part is MED or LOW resolution
-               icon = "ICON_MULTIPR_VIEW_LOW";
-               theResult->SetResolutionMultipr(lPartName, 'L');
-
-               aComment.append("myComment=PART;"); 
-               aComment.append("res=FML;");
-               aComment.append("file=");
-               aComment.append(lMEDFileName);
-             }
-             else
-             {
-               // no resolution associated with this part
-               icon = "ICON_MULTIPR_VIEW_FULL";
-               theResult->SetResolutionMultipr(lPartName, 'F');
-
-               aComment.append("myComment=PART;"); 
-               aComment.append("res=F;");
-               aComment.append("file=");
-               aComment.append(lMEDFileName);
-             }
-           }
-           else
-           {
-             // last part
-             icon = "ICON_MULTIPR_VIEW_FULL";
-             theResult->SetResolutionMultipr(lPartName, 'F');
-
-             aComment.append("myComment=PART;"); 
-             aComment.append("res=FML;");
-             aComment.append("file=");
-             aComment.append(lMEDFileName);
-           }
-
-           lastEntry = CreateAttributes(
-                                        theStudy,
-                                        aMesh->myPartsEntry, // father
-                                        "",
-                                        lPartName,
-                                        aComment.latin1(),
-                                        true,
-                                        icon.latin1());
-         }
-
-         theResult->AddPartMultipr(lPartName, lMEDFileName);
-       }
-      }
-      else
-      {
-       // invalid distributed MED file
-       return;
-      }
-    }
-    catch (...)
-    {
-      throw std::runtime_error("error while reading distributed MED file"); 
-    }
-
-    ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
-  }
-#endif
-
-
-  //---------------------------------------------------------------
-  void
-  BuildMinMax(Result_i* theResult,
-             VISU_Convertor* theInput,
-             CORBA::Boolean* theIsDone,
-             CORBA::Boolean theIsBuild,
-             Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal)
-  {
-    if(!theIsBuild || *theIsDone)
-      return;
-
-    TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildMinMax");
-    TResultManager aResultManager(theResult);
-    
-    theInput->BuildMinMax();
-
-    *theIsDone = true;
-
-    (*theUpdateMinMaxSignal)();
-  }
-
-
-  //---------------------------------------------------------------
-  void
-  BuildFieldDataTree(Result_i* theResult,
-                    VISU_Convertor* theInput,
-                    CORBA::Boolean* theIsFieldsDone,
-                    CORBA::Boolean theIsBuildFields,
-                    CORBA::Boolean* theIsMinMaxDone,
-                    CORBA::Boolean theIsBuildMinMax,
-                    Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal,
-                    _PTR(Study) theStudy)
-  {
-    BuildFields(theResult,
-               theInput,
-               theIsFieldsDone,
-               theIsBuildFields,
-               false,
-               theStudy);
-
-    BuildMinMax(theResult,
-               theInput,
-               theIsMinMaxDone,
-               theIsBuildMinMax,
-               theUpdateMinMaxSignal);
-  }
-
-
-  //---------------------------------------------------------------
-  struct TBuildArgs
-  {
-    Result_i* myResult;
-    VISU_Convertor* myInput;
-    CORBA::Boolean* myIsEntitiesDone;
-    std::string myResultEntry;
-    CORBA::Boolean* myIsFieldsDone;
-    CORBA::Boolean myIsBuildFields;
-    CORBA::Boolean* myIsMinMaxDone;
-    CORBA::Boolean myIsBuildMinMax;
-    Result_i::TUpdateMinMaxSignal* myUpdateMinMaxSignal;
-    CORBA::Boolean* myIsGroupsDone;
-    CORBA::Boolean myIsBuildGroups;
-#ifdef ENABLE_MULTIPR
-    CORBA::Boolean* myIsPartsDone;
-    CORBA::Boolean myIsBuildParts;
-#endif
-    _PTR(Study) myStudy;
-
-    TBuildArgs(Result_i* theResult,
-              VISU_Convertor* theInput,
-              CORBA::Boolean* theIsEntitiesDone,
-              std::string theResultEntry,
-              CORBA::Boolean* theIsFieldsDone,
-              CORBA::Boolean theIsBuildFields,
-              CORBA::Boolean* theIsMinMaxDone,
-              CORBA::Boolean theIsBuildMinMax,
-              Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal,
-              CORBA::Boolean* theIsGroupsDone,
-              CORBA::Boolean theIsBuildGroups,
-#ifdef ENABLE_MULTIPR
-              CORBA::Boolean* theIsPartsDone,
-              CORBA::Boolean theIsBuildParts,
-#endif
-              _PTR(Study) theStudy):
-      myResult(theResult),
-      myInput(theInput),
-      myIsEntitiesDone(theIsEntitiesDone),
-      myResultEntry(theResultEntry),
-      myIsFieldsDone(theIsFieldsDone),
-      myIsBuildFields(theIsBuildFields),
-      myIsMinMaxDone(theIsMinMaxDone),
-      myIsBuildMinMax(theIsBuildMinMax),
-      myUpdateMinMaxSignal(theUpdateMinMaxSignal),
-      myIsGroupsDone(theIsGroupsDone),
-      myIsBuildGroups(theIsBuildGroups),
-#ifdef ENABLE_MULTIPR
-      myIsPartsDone(theIsPartsDone),
-      myIsBuildParts(theIsBuildParts),
-#endif
-      myStudy(theStudy)
-    {}
-  };
-
-  //---------------------------------------------------------------
-  void
-  BuildDataTree(TBuildArgs theBuildArgs)
-  {
-    BuildEntities(theBuildArgs.myResult,
-                 theBuildArgs.myInput,
-                 theBuildArgs.myIsEntitiesDone,
-                 theBuildArgs.myResultEntry,
-                 false,
-                 theBuildArgs.myIsBuildGroups,
-                 theBuildArgs.myIsBuildFields,
-                 theBuildArgs.myStudy);
-
-    {
-      boost::thread aThread(boost::bind(&BuildGroups,
-                                       theBuildArgs.myResult,
-                                       theBuildArgs.myInput,
-                                       theBuildArgs.myIsGroupsDone,
-                                       theBuildArgs.myIsBuildGroups,
-                                       false,
-                                       theBuildArgs.myStudy));
-    }
-    {
-      boost::thread aThread(boost::bind(&BuildFieldDataTree,
-                                       theBuildArgs.myResult,
-                                       theBuildArgs.myInput,
-                                       theBuildArgs.myIsFieldsDone,
-                                       theBuildArgs.myIsBuildFields,
-                                       theBuildArgs.myIsMinMaxDone,
-                                       theBuildArgs.myIsBuildMinMax,
-                                       theBuildArgs.myUpdateMinMaxSignal,
-                                       theBuildArgs.myStudy));
-    }
-
-    /*
-    // MULTIPR
-    BuildParts(theBuildArgs.myResult,
-               theBuildArgs.myInput,
-              theBuildArgs.myIsPartsDone,
-              theBuildArgs.myIsBuildParts,
-              false,
-              theBuildArgs.myStudy);
-    */
-  }
-}
-
-
 //---------------------------------------------------------------
-VISU::MinMaxCunsomer
-::MinMaxCunsomer():
-  myMinMaxIsInitilized(false)
-{}
-
-bool
-VISU::MinMaxCunsomer
-::IsMinMaxInitilized()
-{
-  return myMinMaxIsInitilized;
-}
-
-void
-VISU::MinMaxCunsomer
-::UpdateMinMax()
-{
-  myMinMaxIsInitilized = true;
 }
 
 
@@ -1093,23 +153,15 @@ VISU::Result_i
   myIsBuildFields(theIsBuildFields),
   myIsBuildMinMax(theIsBuildMinMax),
   myIsBuildGroups(theIsBuildGroups),
-#ifdef ENABLE_MULTIPR
-  myIsBuildParts(true),
-#endif
   myIsEntitiesDone(false),
   myIsFieldsDone(false),
   myIsGroupsDone(false),
   myIsMinMaxDone(false),
-#ifdef ENABLE_MULTIPR
-  myIsPartsDone(false),
-#endif
   myIsAllDone(false),
-  myInput(NULL)
+  myIsBuildParts(false),
+  myIsPartsDone(false)
 {
-  myStudy = ProcessEvent(new TGetStudy(myStudyDocument->StudyId()));
-#ifdef ENABLE_MULTIPR
-  myIsDistributedMEDMultipr = false;
-#endif
+  myStudy = VISU::GetStudy(myStudyDocument);
 }
 
 
@@ -1142,9 +194,26 @@ VISU::Result_i
 //---------------------------------------------------------------
 void 
 VISU::Result_i
-::MinMaxConnect(VISU::MinMaxCunsomer* theMinMaxCunsomer)
+::ConnectObserver(TResultObserver* theObserver,
+                 boost::signalslib::connection& theConnection)
 {
-  myUpdateMinMaxSignal.connect(boost::bind(&MinMaxCunsomer::UpdateMinMax,theMinMaxCunsomer));
+  if(theConnection.connected())
+    theConnection.disconnect();
+
+  theConnection = 
+    myUpdateObserverSignal.connect(boost::bind(boost::bind(&TResultObserver::UpdateFromResult, 
+                                                          theObserver, 
+                                                          _1),
+                                              this));
+}
+
+
+//---------------------------------------------------------------
+void 
+VISU::Result_i
+::UpdateObservers()
+{
+  myUpdateObserverSignal();
 }
 
 
@@ -1263,7 +332,7 @@ VISU::Result_i
   if(theIsBuildAll)
     theIsAtOnce = true;
 
-  if(Build(SALOMEDS::SObject::_nil(),theIsAtOnce)){
+  if(Build(SALOMEDS::SObject::_nil(), theIsAtOnce)){
     
     // Set icon
     SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
@@ -1304,17 +373,19 @@ VISU::Result_i
                   GetComment(),
                   myFileInfo.filePath().latin1(),
                   myInitFileName.c_str()); // Restoring of Python dump
-  string aResultEntry =
+  std::string aResultEntry = 
     CreateAttributes(myStudy,
                     aSComponentEntry.in(),
+                    NO_ICON,
                     anIOR.in(),
                     myName,
+                    NO_PERFSITENT_REF,
                     aComment.latin1(),
                     true);
   mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str());
   if(!CORBA::is_nil(theSObject)){
     CORBA::String_var aString = theSObject->GetID();
-    CreateReference(myStudyDocument,aResultEntry,aString.in());
+    CreateReference(myStudyDocument, aResultEntry, aString.in());
   }
 
   if(theIsAtOnce){
@@ -1325,6 +396,7 @@ VISU::Result_i
                  theIsAtOnce,
                  myIsBuildGroups,
                  myIsBuildFields,
+                 myIsBuildParts,
                  myStudy);
     
     BuildGroups(this,
@@ -1344,91 +416,53 @@ VISU::Result_i
     BuildMinMax(this,
                myInput,
                &myIsMinMaxDone,
-               myIsBuildMinMax,
-               &myUpdateMinMaxSignal);
-
-#ifdef ENABLE_MULTIPR
-    // MULTIPR
-    BuildParts(this,
-              myInput,
-              &myIsPartsDone,
-              myIsBuildParts,
-              theIsAtOnce,
-              myStudy);
-#endif
+               myIsBuildMinMax);
   }
   else {
-#ifdef ENABLE_MULTIPR
-    if (strlen(GetFileInfoMultipr().filePath().latin1()) == 0)
-#endif
-    {
-      // sequential MED file
-      TBuildArgs aBuildArgs(this,
-                           myInput,
-                           &myIsEntitiesDone,
-                           aResultEntry,
-                           &myIsFieldsDone,
-                           myIsBuildFields,
-                           &myIsMinMaxDone,
-                           myIsBuildMinMax,
-                           &myUpdateMinMaxSignal,
-                           &myIsGroupsDone,
-                           myIsBuildGroups,
-#ifdef ENABLE_MULTIPR
-                           &myIsPartsDone,
-                           myIsBuildParts,
-#endif
-                           myStudy);
-      boost::thread aThread(boost::bind(&BuildDataTree, aBuildArgs));
-    }
-#ifdef ENABLE_MULTIPR
-    else
-    {
-      // distributed MED file
-      BuildEntities(this,
-                   myInput,
-                   &myIsEntitiesDone,
-                   aResultEntry,
-                   theIsAtOnce,
-                   myIsBuildGroups,
-                   myIsBuildFields,
-                   myStudy);
-
-      BuildGroups(this,
-                 myInput,
-                 &myIsGroupsDone,
-                 myIsBuildGroups,
-                 theIsAtOnce,
-                 myStudy);
-
-      BuildFields(this,
-                 myInput,
-                 &myIsFieldsDone,
-                 myIsBuildFields,
-                 theIsAtOnce,
-                 myStudy);
-
-      BuildMinMax(this,
-                 myInput,
-                 &myIsMinMaxDone,
-                 myIsBuildMinMax,
-                 &myUpdateMinMaxSignal);
-
-      // MULTIPR
-      BuildParts(this,
-                myInput,
-                &myIsPartsDone,
-                myIsBuildParts,
-                theIsAtOnce,
-                myStudy);
-    }
-#endif
+    boost::thread aThread(boost::bind(boost::bind(&Result_i::BuildDataTree, this, _1),
+                                     aResultEntry));
   }
 
   return this;
 }
 
 
+//---------------------------------------------------------------
+void
+VISU::Result_i
+::BuildDataTree(const std::string& theResultEntry)
+{
+  BuildEntities(this,
+               myInput,
+               &myIsEntitiesDone,
+               theResultEntry,
+               false,
+               myIsBuildGroups,
+               myIsBuildFields,
+               myIsBuildParts,
+               myStudy);
+
+  {
+    boost::thread aThread(boost::bind(&BuildGroups,
+                                     this,
+                                     myInput,
+                                     &myIsGroupsDone,
+                                     myIsBuildGroups,
+                                     false,
+                                     myStudy));
+  }
+  {
+    boost::thread aThread(boost::bind(&BuildFieldDataTree,
+                                     this,
+                                     myInput,
+                                     &myIsFieldsDone,
+                                     myIsBuildFields,
+                                     &myIsMinMaxDone,
+                                     myIsBuildMinMax,
+                                     myStudy));
+  }
+}
+
 //---------------------------------------------------------------
 VISU::Storable*
 VISU::Result_i
@@ -1457,46 +491,8 @@ Create(const char* theFileName)
 {      
   try {
     myFileInfo.setFile(theFileName);
-
-#ifdef ENABLE_MULTIPR
-    // MULTIPR    
-    if (myFileInfo.filePath().endsWith("_grains_maitre.med"))
-    {
-      // retrieve source MED file (sequential MED file)
-      QString originalMEDFileName = "";
-      FILE* aFile = fopen(theFileName, "rt");
-      char aBuf[1024];
-      while (!feof(aFile))
-      {
-       fgets(aBuf, 1024, aFile);
-       char* strTag = NULL;
-       if ((aBuf[0] == '#') && ((strTag = strstr(aBuf, "[SOURCE]=")) != NULL))
-       {
-         char strSequentialMEDFilename[256];
-         int ret = sscanf(strTag, "[SOURCE]=%s", strSequentialMEDFilename);
-         if (ret == 1)
-         {
-           originalMEDFileName = strSequentialMEDFilename;
-           break;
-         }
-       }
-      }
-      fclose(aFile);
-      if (originalMEDFileName == "") 
-       throw std::runtime_error("distributed MED file; bad format"); 
-
-      //cout << "MULTIPR: original med file=" << originalMEDFileName << endl;
-      myFileInfoMultipr.setFile(myFileInfo.filePath());
-      myFileInfo.setFile(originalMEDFileName);
-    }
-    else
-    {
-      myFileInfoMultipr.setFile("");
-    }
-#endif
-
     myInitFileName = myFileInfo.filePath().latin1();
-    myName = ::GenerateName(myFileInfo.fileName()).latin1();
+    myName = VISU::GenerateName(myFileInfo.fileName()).latin1();
     if(mySourceId == eRestoredFile){
       std::string aTmpDir(SALOMEDS_Tool::GetTmpDir());
       static QString aCommand;
@@ -1512,7 +508,7 @@ Create(const char* theFileName)
       myFileInfo.setFile(QString(aTmpDir.c_str()) + myFileInfo.fileName());
     }
 
-    myInput = CreateConvertor(myFileInfo.absFilePath().latin1());
+    myInput.reset(CreateConvertor(myFileInfo.absFilePath().latin1()));
 
     if(myInput){
       if(myIsBuildImmediately)
@@ -1535,8 +531,8 @@ VISU::Result_i
 {
   if(MYDEBUG)  MESSAGE("Result_i::Create MedObject from SALOMEDS::SObject_ptr");
   try{
-    myInput = CreateMEDConvertor(theMedSObject);
-    if(myInput == NULL)
+    myInput.reset(CreateMEDConvertor(theMedSObject));
+    if(!myInput)
       return NULL;
 
     myInput->Build();
@@ -1545,7 +541,7 @@ VISU::Result_i
     myFileInfo.setFile(aCompDataType.c_str());
     myInitFileName = aCompDataType;
 
-    myName = ::GenerateName("aResult").latin1();
+    myName = VISU::GenerateName("aResult").latin1();
 
     return Build(theMedSObject);
   }catch(std::exception& exc){
@@ -1564,8 +560,8 @@ VISU::Result_i
 {
   if(MYDEBUG)  MESSAGE("Result_i::Create MedObject from SALOME_MED::FIELD_ptr");
   try{
-    myInput = CreateMEDFieldConvertor(theField);
-    if(myInput == NULL)
+    myInput.reset(CreateMEDFieldConvertor(theField));
+    if(!myInput)
       return NULL;
 
     myInput->Build();
@@ -1574,7 +570,7 @@ VISU::Result_i
     myFileInfo.setFile(aCompDataType.c_str());
     myInitFileName = aCompDataType;
 
-    myName = ::GenerateName("aResult").latin1();
+    myName = VISU::GenerateName("aResult").latin1();
 
     CORBA::String_var anIOR = myStudyDocument->ConvertObjectToIOR(theField);
     SALOMEDS::SObject_var aFieldSObject = myStudyDocument->FindObjectIOR(anIOR);
@@ -1620,31 +616,17 @@ VISU::Result_i
       SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
       SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aEngComp);
       aStudyBuilder->LoadWith(aCompRefSObj, aDriver);
-      /*
-      if (strcmp(aDataType, "MED") == 0){
-        // create field or MED converter
-        CORBA::Object_var aMedObject = VISU::SObjectToObject(aTargetRefSObj);
-        SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(aMedObject);
-        if(!CORBA::is_nil(aField))
-          myInput = CreateMEDFieldConvertor(aField);
-        else
-          myInput = CreateMEDConvertor(aTargetRefSObj);
-       myInput->Build();
-      }else
-       throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!");
-      //*/
-
       // create field or MED converter
       CORBA::Object_var aMedObject = VISU::SObjectToObject(aTargetRefSObj);
       SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(aMedObject);
       if (!CORBA::is_nil(aField)) {
         // create field converter
-       myInput = CreateMEDFieldConvertor(aField);
+       myInput.reset(CreateMEDFieldConvertor(aField));
        myInput->Build();
       }
       else if (strcmp(aDataType, "MED") == 0) {
         // create MED converter
-       myInput = CreateMEDConvertor(aTargetRefSObj);
+       myInput.reset(CreateMEDConvertor(aTargetRefSObj));
        myInput->Build();
       }
       else {
@@ -1708,7 +690,7 @@ VISU::Result_i
        mySourceId = eFile;
       }
       if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = " << mySourceId);
-      myInput = CreateConvertor(myFileInfo.filePath().latin1());
+      myInput.reset(CreateConvertor(myFileInfo.filePath().latin1()));
 
       myInput->BuildEntities();
       if(myIsBuildFields){
@@ -1747,14 +729,27 @@ VISU::Result_i
   return NULL;
 }
 
+
 //---------------------------------------------------------------
-VISU::Result_i::TInput* 
+void
 VISU::Result_i
-::GetInput() 
+::SetResolution(const std::string& theName, 
+               TResolutionID theNewResolution) 
+{}
+
+
+//---------------------------------------------------------------
+VISU::Result_i::PInput
+VISU::Result_i
+::GetInput(const std::string& theMeshName, 
+          VISU::Entity theEntity,
+          const std::string& theFieldName, 
+          CORBA::Long theTimeStampNumber) 
 {
   return myInput;
 }
 
+
 //---------------------------------------------------------------
 CORBA::Boolean 
 VISU::Result_i
@@ -1815,17 +810,23 @@ VISU::Result_i
 }
 
 //---------------------------------------------------------------
-void 
+VISU::Result_i*
 VISU::Result_i
-::ToStream(std::ostringstream& theStr)
+::New(SALOMEDS::Study_ptr theStudy,
+      const ESourceId& theSourceId,
+      const ECreationId& theCreationId,
+      CORBA::Boolean theIsBuildImmediately,
+      CORBA::Boolean theIsBuildFields,
+      CORBA::Boolean theIsBuildMinMax,
+      CORBA::Boolean theIsBuildGroups)
 {
-  if(MYDEBUG) MESSAGE(GetComment());
-  Storable::DataToStream(theStr,"myName",myName.c_str());
-  Storable::DataToStream(theStr,"myInitFileName",myInitFileName.c_str());
-  Storable::DataToStream(theStr,"myCreationId",myCreationId);
-  Storable::DataToStream(theStr,"myIsBuildFields",myIsFieldsDone);
-  Storable::DataToStream(theStr,"myIsBuildMinMax",myIsMinMaxDone);
-  Storable::DataToStream(theStr,"myIsBuildGroups",myIsGroupsDone);
+  return new RESULT_CLASS_NAME(theStudy,
+                              theSourceId,
+                              theCreationId,
+                              theIsBuildImmediately,
+                              theIsBuildFields,
+                              theIsBuildMinMax,
+                              theIsBuildGroups);
 }
 
 
@@ -1847,27 +848,68 @@ VISU::Result_i
   CORBA::Boolean anIsBuildMinMax = Storable::FindValue(theMap,"myIsBuildMinMax","1").toInt();
   CORBA::Boolean anIsBuildGroups = Storable::FindValue(theMap,"myIsBuildGroups","1").toInt();
 
-  VISU::Result_i* aResult = new VISU::Result_i(aStudy,
-                                              aSourceId,
-                                              aCreationId,
-                                              anIsBuildFields,
-                                              anIsBuildMinMax,
-                                              anIsBuildGroups);
+  VISU::Result_i* aResult = new RESULT_CLASS_NAME(aStudy,
+                                                 aSourceId,
+                                                 aCreationId,
+                                                 anIsBuildFields,
+                                                 anIsBuildMinMax,
+                                                 anIsBuildGroups);
   if (aResult == NULL)
     return NULL;
 
-  return aResult->Restore(theSObject,theMap,thePrefix);
+  return aResult->Restore(theSObject, theMap, thePrefix);
 }
 
 
 //---------------------------------------------------------------
-string 
+void 
+VISU::Result_i
+::ToStream(std::ostringstream& theStr)
+{
+  if(MYDEBUG) MESSAGE(GetComment());
+  Storable::DataToStream(theStr,"myName",myName.c_str());
+  Storable::DataToStream(theStr,"myInitFileName",myInitFileName.c_str());
+  Storable::DataToStream(theStr,"myCreationId",myCreationId);
+  Storable::DataToStream(theStr,"myIsBuildFields",myIsFieldsDone);
+  Storable::DataToStream(theStr,"myIsBuildMinMax",myIsMinMaxDone);
+  Storable::DataToStream(theStr,"myIsBuildGroups",myIsGroupsDone);
+}
+
+
+//---------------------------------------------------------------
+const std::string&
+VISU::Result_i
+::GetName() const
+{
+  return myName;
+}
+
+
+const QFileInfo&
+VISU::Result_i
+::GetFileInfo() const
+{
+  return myFileInfo;
+}
+
+
+const std::string&
+VISU::Result_i
+::GetFileName() const
+{
+  return myInitFileName;
+}
+
+
+const VISU::Result_i::ECreationId&
 VISU::Result_i
-::GetRefFatherEntry() 
+::GetCreationId() const
 {
-  return "";
+  return myCreationId;
 }
 
+
+//---------------------------------------------------------------
 std::string
 VISU::Result_i
 ::GetEntry()
@@ -1890,6 +932,13 @@ VISU::Result_i
   return myStudyDocument;
 }
 
+_PTR(Study) 
+VISU::Result_i
+::GetStudy() const 
+{ 
+  return myStudy;
+}
+
 const SALOMEDS::SComponent_var& 
 VISU::Result_i
 ::GetSComponent() const
@@ -1931,15 +980,14 @@ VISU::Result_i
     res = system(aCommand);
     MESSAGE("Result_i::~Result_i - system("<<aCommand<<") = "<<res);
   }
-  if(myInput) delete myInput;
 }
 
 //=======================================================================
 //function : GetAxisInfo
 //purpose  :
 //=======================================================================
-const Result_i::TAxisInfo* 
-Result_i
+const VISU::Result_i::TAxisInfo* 
+VISU::Result_i
 ::GetAxisInfo(const string& theMeshName,
              TAxis         theAxis,
              gp_Dir&       thePlaneNormal)
@@ -2196,94 +1244,3 @@ Result_i
 
   return components;
 }
-
-
-#ifdef ENABLE_MULTIPR
-//=======================================================================
-// MULTIPR
-//=======================================================================
-
-// MULTIPR
-void VISU::Result_i::AddPartMultipr(const char* thePartName, const char* theMEDFilename)
-{
-  myMapPartNameToMEDFilename.insert(make_pair(thePartName, theMEDFilename));
-}
-
-// MULTIPR
-void VISU::Result_i::SetResolutionMultipr(const char* theName, char theNewResolution)
-{
-  map<string, char>::iterator anIterator = mySelectedResolutionMultipr.find(theName);
-
-  if (anIterator == mySelectedResolutionMultipr.end())
-  {
-    // current name does not exist: create
-    mySelectedResolutionMultipr.insert(make_pair(theName, theNewResolution));
-  }
-  else
-  {
-    // modify
-    (*anIterator).second = theNewResolution;
-  }
-}
-
-// MULTIPR
-string VISU::Result_i::FindPartMultipr(const char* theName)
-{
-  map<string, string>::iterator anIterator = myMapPartNameToMEDFilename.find(theName);
-
-  if (anIterator == myMapPartNameToMEDFilename.end())
-  {
-    return NULL;
-  }
-  return (*anIterator).second;
-}
-
-// MULTIPR
-void VISU::Result_i::SetIsDistributedMEDMultipr(bool theIsDistributedMED)
-{
-  myIsDistributedMEDMultipr = theIsDistributedMED;
-}
-
-// MULTIPR
-bool VISU::Result_i::IsDistributedMEDMultipr() const
-{
-  return myIsDistributedMEDMultipr;
-}
-
-// MULTIPR
-vector<string> VISU::Result_i::GetCurrentRepresentationMultipr()
-{
-  // name of selected parts
-  vector<string> res;
-
-  // for each part of the mesh
-  for (map<string, char>::iterator it = mySelectedResolutionMultipr.begin() ; 
-       it != mySelectedResolutionMultipr.end() ; 
-       it++)
-  {
-    const char* partName = ((*it).first).c_str();
-    char resolution = (*it).second;
-
-    //cout << "name=" << partName << " res=" << resolution << endl;
-
-    if (resolution == 'F')
-    {
-      res.push_back( FindPartMultipr(partName) );
-    } 
-    else if (resolution == 'M')
-    {
-      char subPartName[256];
-      sprintf(subPartName, "%s_MED", partName);
-      res.push_back( FindPartMultipr(subPartName) );
-    }
-    else if (resolution == 'L')
-    {
-      char subPartName[256];
-      sprintf(subPartName, "%s_LOW", partName);
-      res.push_back( FindPartMultipr(subPartName) );
-    }
-  }
-
-  return res;
-}
-#endif // ENABLE_MULTIPR
index 4ef575d048a1c4bbf2d9904e4b71c93cdd96cf85..bd8ec41ddb3a3272b1fa725e0a12c6112b0efa91 100644 (file)
 #include "VISU_BoostSignals.h"
 #include "SALOME_GenericObj_i.hh"
 
+#include "SALOME_Event.hxx"
 #include "VTKViewer.h"
 
+#include <boost/shared_ptr.hpp>
 #include <gp_Dir.hxx>
 #include <vector>
 #include <map>
@@ -42,27 +44,22 @@ class VISU_Convertor;
 namespace VISU
 {
   //----------------------------------------------------------------------------
-  class VISU_I_EXPORT MinMaxCunsomer: public virtual boost::signalslib::trackable
-  {
-  protected:
-    bool myMinMaxIsInitilized;
-    MinMaxCunsomer();
+  class Result_i;
 
-  public:
-    virtual
-    bool
-    IsMinMaxInitilized();
 
+  //----------------------------------------------------------------------------
+  struct TResultObserver: public virtual boost::signalslib::trackable
+  {
     virtual
     void
-    UpdateMinMax();
+    UpdateFromResult(Result_i* theResult) = 0;
   };
 
 
   //----------------------------------------------------------------------------
   class VISU_I_EXPORT Result_i : public virtual POA_VISU::Result,
-                   public virtual RemovableObject_i,
-                  public virtual SALOME::GenericObj_i
+                                public virtual RemovableObject_i,
+                                public virtual SALOME::GenericObj_i
   {
     Result_i(const Result_i &);
 
@@ -70,136 +67,221 @@ namespace VISU
     enum ESourceId {eRestoredComponent = -2, eRestoredFile = -1, eFile = 1, eComponent = 2};
     enum ECreationId {eImportFile, eCopyAndImportFile, eImportMed, eImportMedField};
 
-    Result_i(SALOMEDS::Study_ptr theStudy,
-            const ESourceId& theSourceId,
-            const ECreationId& theCreationId,
-            CORBA::Boolean theIsBuildImmediately = true,
-            CORBA::Boolean theIsBuildFields = true,
-            CORBA::Boolean theIsBuildMinMax = true,
-            CORBA::Boolean theIsBuildGroups = true);
+    static
+    Result_i*
+    New(SALOMEDS::Study_ptr theStudy,
+       const ESourceId& theSourceId,
+       const ECreationId& theCreationId,
+       CORBA::Boolean theIsBuildImmediately = true,
+       CORBA::Boolean theIsBuildFields = true,
+       CORBA::Boolean theIsBuildMinMax = true,
+       CORBA::Boolean theIsBuildGroups = true);
+    
+    virtual
+    void
+    RemoveFromStudy();
 
-    virtual ~Result_i();
-    virtual void RemoveFromStudy();
+    virtual
+    VISU::VISUType 
+    GetType() 
+    {
+      return VISU::TRESULT;
+    }
 
-    virtual VISU::VISUType GetType() { return VISU::TRESULT;}
-    virtual CORBA::Boolean BuildAll();
+    virtual
+    CORBA::Boolean
+    BuildAll();
 
-    virtual CORBA::Boolean Build(CORBA::Boolean theIsBuildAll,
-                                CORBA::Boolean theIsAtOnce);
-    virtual CORBA::Boolean IsDone();
+    virtual
+    CORBA::Boolean 
+    Build(CORBA::Boolean theIsBuildAll,
+         CORBA::Boolean theIsAtOnce);
 
-    virtual CORBA::Boolean IsEntitiesDone();
+    virtual
+    CORBA::Boolean
+    IsDone();
 
-    virtual void SetBuildFields(CORBA::Boolean theIsBuildFields, 
-                               CORBA::Boolean theIsCalculateMinMax);
-    virtual CORBA::Boolean IsFieldsDone();
+    virtual
+    CORBA::Boolean
+    IsEntitiesDone();
 
-    virtual void SetBuildGroups(CORBA::Boolean theIsBuildGroups);
-    virtual CORBA::Boolean IsGroupsDone();
+    virtual
+    void
+    SetBuildFields(CORBA::Boolean theIsBuildFields, 
+                  CORBA::Boolean theIsCalculateMinMax);
 
-    virtual CORBA::Boolean IsMinMaxDone();
+    virtual
+    CORBA::Boolean
+    IsFieldsDone();
+
+    virtual
+    void 
+    SetBuildGroups(CORBA::Boolean theIsBuildGroups);
+
+    virtual
+    CORBA::Boolean
+    IsGroupsDone();
+
+    virtual
+    CORBA::Boolean
+    IsMinMaxDone();
 
     virtual 
     void
-    MinMaxConnect(MinMaxCunsomer* theMinMaxCunsomer);
+    UpdateObservers();
 
-    typedef boost::signal0<void> TUpdateMinMaxSignal;
+    virtual 
+    void
+    ConnectObserver(TResultObserver* theObserver,
+                   boost::signalslib::connection& theConnection);
+
+    typedef boost::signal0<void> TUpdateObserverSignal;
 
     typedef VISU_Convertor TInput;
+    typedef boost::shared_ptr<TInput> PInput;
 
   private:
     ESourceId mySourceId;
     ECreationId myCreationId;
 
-    TInput *myInput;
-       std::string myName, myInitFileName;
+    PInput myInput;
+    std::string myName;
     QFileInfo myFileInfo;
-
-#ifdef ENABLE_MULTIPR
-    // MULTIPR
-    QFileInfo                          myFileInfoMultipr;
-    std::map<std::string, std::string> myMapPartNameToMEDFilename;
-    std::map<std::string, char>        mySelectedResolutionMultipr;
-    bool                               myIsDistributedMEDMultipr;
-#endif
+    std::string myInitFileName;
 
   protected:
-    virtual Storable* Build(SALOMEDS::SObject_ptr theSObject,
-                           CORBA::Boolean theIsAtOnce = true) ;
-    virtual Storable* BuildAll(SALOMEDS::SObject_ptr theSObject) ;
+    Result_i(SALOMEDS::Study_ptr theStudy,
+            const ESourceId& theSourceId,
+            const ECreationId& theCreationId,
+            CORBA::Boolean theIsBuildImmediately = true,
+            CORBA::Boolean theIsBuildFields = true,
+            CORBA::Boolean theIsBuildMinMax = true,
+            CORBA::Boolean theIsBuildGroups = true);
+
+    virtual
+    ~Result_i();
+
+    virtual
+    Storable* 
+    Build(SALOMEDS::SObject_ptr theSObject,
+         CORBA::Boolean theIsAtOnce = true) ;
+
+    virtual
+    void
+    BuildDataTree(const std::string& theResultEntry);
+
+    virtual
+    Storable* 
+    BuildAll(SALOMEDS::SObject_ptr theSObject) ;
 
     _PTR(Study) myStudy;
     CORBA::Boolean myIsBuildImmediately;
 
     CORBA::Boolean myIsEntitiesDone;
-    CORBA::Boolean myIsFieldsDone;
-    CORBA::Boolean myIsGroupsDone;
-    CORBA::Boolean myIsMinMaxDone;
-#ifdef ENABLE_MULTIPR
-    CORBA::Boolean myIsPartsDone; // MULTIPR
-#endif
 
+    CORBA::Boolean myIsFieldsDone;
     CORBA::Boolean myIsBuildFields;
+
+    CORBA::Boolean myIsGroupsDone;
     CORBA::Boolean myIsBuildGroups;
 
+    CORBA::Boolean myIsPartsDone;
+    CORBA::Boolean myIsBuildParts;
+
+    CORBA::Boolean myIsMinMaxDone;
     CORBA::Boolean myIsBuildMinMax;
-#ifdef ENABLE_MULTIPR
-    CORBA::Boolean myIsBuildParts; // MULTIPR
-#endif
-    TUpdateMinMaxSignal myUpdateMinMaxSignal;
+    TUpdateObserverSignal myUpdateObserverSignal;
 
     CORBA::Boolean myIsAllDone;
 
   public:
-    virtual size_t IsPossible();
+    virtual
+    size_t
+    IsPossible();
+
+    virtual
+    Storable* 
+    Create(const char* theFileName);
+
+    virtual
+    Storable* 
+    Create(SALOMEDS::SObject_ptr theMedSObject);
+
+    virtual
+    Storable* 
+    Create(SALOME_MED::FIELD_ptr theField);
 
-    virtual Storable* Create(const char* theFileName);
-    virtual Storable* Create(SALOMEDS::SObject_ptr theMedSObject);
-    virtual Storable* Create(SALOME_MED::FIELD_ptr theField);
+    virtual
+    Storable* 
+    Restore(SALOMEDS::SObject_ptr theSObject,
+           const Storable::TRestoringMap& theMap,
+           const std::string& thePrefix);
+
+    static 
+    Storable* 
+    Restore(SALOMEDS::SObject_ptr theSObject,
+           const std::string& thePrefix,
+           const Storable::TRestoringMap& theMap);
 
-    virtual Storable* Restore(SALOMEDS::SObject_ptr theSObject,
-                             const Storable::TRestoringMap& theMap,
-                             const std::string& thePrefix);
+    virtual 
+    void
+    ToStream(std::ostringstream& theStr);
 
-    static Storable* Restore(SALOMEDS::SObject_ptr theSObject,
-                            const std::string& thePrefix,
-                            const Storable::TRestoringMap& theMap);
+    virtual
+    const char* 
+    GetComment() const;
 
-    virtual void ToStream(std::ostringstream& theStr);
-    virtual const char* GetComment() const;
     static const std::string myComment;
-    TInput* GetInput();
 
-    const std::string& GetName() const { return myName;}
-    const QFileInfo& GetFileInfo() const { return myFileInfo;}
-#ifdef ENABLE_MULTIPR
-    const QFileInfo& GetFileInfoMultipr() const { return myFileInfoMultipr;}
-#endif
-    const std::string& GetFileName() const { return myInitFileName;}
-    const ECreationId& GetCreationId() const { return myCreationId;}
-       
-#ifdef ENABLE_MULTIPR
-    // MULTIPR
-    void AddPartMultipr(const char* thePartName, const char* theMEDFilename);
-    void SetResolutionMultipr(const char* theName, char theNewResolution); // 'F'=FULL  'M'=MEDIUM  'L'=LOW  'H'=HIDE 
-    std::string FindPartMultipr(const char* theName);
-    std::vector<std::string> GetCurrentRepresentationMultipr();
-    void SetIsDistributedMEDMultipr(bool theIsDistributedMED);
-    bool IsDistributedMEDMultipr() const;
-#endif
+    typedef char TResolutionID;
+
+    virtual
+    void
+    SetResolution(const std::string& theName, 
+                 TResolutionID theNewResolution);
 
+    virtual
+    PInput 
+    GetInput(const std::string& theMeshName = "",
+            VISU::Entity theEntity = VISU::NONE,
+            const std::string& theFieldName = "", 
+            CORBA::Long theTimeStampNumber = -1);
+
+    const std::string& 
+    GetName() const;
+
+    const QFileInfo& 
+    GetFileInfo() const;
+
+    const std::string& 
+    GetFileName() const;
+
+    const ECreationId& 
+    GetCreationId() const;
+       
   private:
     SALOMEDS::SObject_var mySObject;
     SALOMEDS::Study_var myStudyDocument;
     SALOMEDS::SComponent_var mySComponent;
 
   public:
-    std::string GetRefFatherEntry();
-    std::string GetEntry();
-    const SALOMEDS::SObject_var& GetSObject() const;
-    const SALOMEDS::Study_var& GetStudyDocument() const;
-    const SALOMEDS::SComponent_var& GetSComponent() const;
-    std::string GetEntry(const Storable::TRestoringMap& theRestoringMap);
+    std::string
+    GetEntry();
+
+    const SALOMEDS::SObject_var& 
+    GetSObject() const;
+
+    const SALOMEDS::Study_var& 
+    GetStudyDocument() const;
+
+    _PTR(Study) 
+    GetStudy() const;
+
+    const SALOMEDS::SComponent_var& 
+    GetSComponent() const;
+
+    std::string
+    GetEntry(const Storable::TRestoringMap& theRestoringMap);
 
     // Info on structured mesh contained in TInput
   public:
index 2dacbee64124eabcd907e3ab33ff5455fc0dbe38..a6d4e3403dbbbb027711315c2dd5834a73908fc8 100644 (file)
@@ -65,7 +65,7 @@ VISU::ScalarMapOnDeformedShape_i
                                      theTimeStampNumber,
                                      false);
     if(theIsMemoryCheck && aResult){
-      VISU::Result_i::TInput* anInput = theResult->GetInput();
+      VISU::Result_i::PInput anInput = theResult->GetInput();
       const VISU::PField aField = anInput->GetField(theMeshName,
                                                    (VISU::TEntity)theEntity,
                                                    theFieldName);
@@ -328,7 +328,7 @@ VISU::ScalarMapOnDeformedShape_i
     return;
 
   VISU::TEntity aEntity = VISU::TEntity(theEntity);
-  VISU::Result_i::TInput* anInput = GetCResult()->GetInput();
+  VISU::Result_i::PInput anInput = GetCResult()->GetInput();
   myScalarField = anInput->GetField(GetCMeshName(), aEntity, theFieldName);
 
   VISU::PUnstructuredGridIDMapper anIDMapper = 
index 3a82f2be5abe911149e3635ae9e19ccb81446d93..746bd9778300ad0949644f0517a13a58660c4c92 100644 (file)
@@ -67,7 +67,7 @@ VISU::ScalarMap_i
   try{
     if(theResult){
       bool anIsEstimated = true;
-      VISU::Result_i::TInput* anInput = theResult->GetInput();
+      VISU::Result_i::PInput anInput = theResult->GetInput();
       size_t aSize = anInput->GetTimeStampOnMeshSize(theMeshName,
                                                     (VISU::TEntity)theEntity,
                                                     theFieldName,
@@ -375,7 +375,7 @@ void
 VISU::ScalarMap_i
 ::AddMeshOnGroup(const char* theGroupName)
 {
-  VISU::Result_i::TInput* anInput = GetCResult()->GetInput();
+  VISU::Result_i::PInput anInput = GetCResult()->GetInput();
   VISU::PUnstructuredGridIDMapper anIDMapper = anInput->GetMeshOnGroup(GetCMeshName(), theGroupName);
   if(anIDMapper){
     int aNbGroups  = myGroupNames.size();
@@ -407,7 +407,7 @@ void
 VISU::ScalarMap_i
 ::DoSetInput(bool theIsInitilizePipe, bool theReInit)
 {
-  VISU::Result_i::TInput* anInput = GetCResult()->GetInput();
+  VISU::Result_i::PInput anInput = GetCResult()->GetInput();
   if(!anInput)
     throw std::runtime_error("Mesh_i::Build - GetCResult()->GetInput() == NULL !!!");
 
index 86f4cbe045c3594ae1fd340cbb2e97433a49fda8..1a2149b38369e1768b80b19edb034fbfe69764bf 100644 (file)
@@ -59,7 +59,7 @@ VISU::StreamLines_i
     if(!TSuperClass::IsPossible(theResult, theMeshName, theEntity, theFieldName, theTimeStampNumber, false)) 
       return 0;
 
-    VISU::Result_i::TInput* anInput = theResult->GetInput();
+    VISU::Result_i::PInput anInput = theResult->GetInput();
     VISU::PUnstructuredGridIDMapper anIDMapper = 
       anInput->GetTimeStampOnMesh(theMeshName,
                                  VISU::TEntity(theEntity),
index 8434c0134f84567f2327af1355c359cd38d0693b..0d9fe4070a5cd4cb284b879d655037f19f8269b3 100644 (file)
@@ -65,7 +65,7 @@ VISU::Vectors_i
                                             false);
     if(theIsMemoryCheck && aResult){
       bool anIsEstimated = true;
-      VISU::Result_i::TInput* anInput = theResult->GetInput();
+      VISU::Result_i::PInput anInput = theResult->GetInput();
       size_t aSize = anInput->GetTimeStampOnMeshSize(theMeshName,
                                                     (VISU::TEntity)theEntity,
                                                     theFieldName,