Back to index

salome-paravis  6.5.0
Classes | Typedefs | Functions
PARAVIS Namespace Reference

The main package of interfaces of the module PARAVIS. More...

Classes

interface  PARAVIS_Base
 Base class for all PARAVIS container(wrapper) classes. More...
interface  PARAVIS_Gen
 The main interface class for PARAVIS server. More...
class  PARAVIS_Gen_i
 Implements PARAVIS_Gen interface. More...
struct  TSetStudyEvent
class  PARAVIS_Base_i
 Base implementation for all container objects for Paravis serevrmanager API classes. More...
struct  TGetGUIApplication
 Event which returns SalomeApp_Application instance which corresponds to th given study ID. More...
struct  TModuleEvent
 Parent event for all events what is going to work with PARAVIS module instance. More...
struct  TActivateModule
 Event which activates PARAVIS module if it is not active. More...
struct  TGetTrace
 Returns trace string collected in PARAVIS module in current session. More...
struct  TParavisFileEvent
 Parent event for all operations with files across PARAVIS module. More...
struct  TSaveTrace
 Event to save trace string inte disk file. More...
struct  TImportFile
 Event to import file to PARAVIS. More...
struct  TExecuteScript
 Event to execute a script to PARAVIS. More...
struct  TSaveStateFile
 Event to save current Paraview state. More...
struct  TLoadStateFile
 Event to restore Paraview state from disk file. More...
struct  TGetActiveServer
 Returns currently active Paraview server. More...

Typedefs

typedef string function
typedef sequence< string > string_array
typedef sequence< short > short_array
typedef sequence< long > long_array
typedef sequence< float > float_array
typedef sequence< double > double_array
typedef sequence< char > char_array

Functions

const char * checkNullStr (const char *theStr)
std::string tabify (const std::string &source, bool isTabify)
void processElements (QDomNode &thePropertyNode, QStringList &theFileNames, const char *theNewPath, bool theRestore)
void processProperties (QDomNode &theProxyNode, QStringList &theFileNames, const char *theNewPath, bool theRestore)
void processProxies (QDomNode &theNode, QStringList &theFileNames, const char *theNewPath, bool theRestore)
bool processAllFilesInState (const char *aFileName, QStringList &theFileNames, const char *theNewPath, bool theRestore=false)
QStringList getAllSavedStates (SALOMEDS::SComponent_ptr theComponent, QString theNewPath=QString())
SALOMEDS::TMPFile * SaveState (long thePID, SalomeApp_Application *theApp, SALOMEDS::SComponent_ptr theComponent, const char *theURL, bool isMultiFile)
bool LoadState (SalomeApp_Application *theApp, SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile &theStream, const char *theURL, bool isMultiFile)
SALOMEDS::ListOfFileNames * GetListOfFileNames (const QStringList &theFileNames)
SALOMEDS::SComponent_var FindOrCreateParaVisComponent (SALOMEDS::Study_ptr theStudyDocument)
PARAVIS_Base_iGET_SERVANT (CORBA::Object_ptr aObj)
void SetRestoreParam (SALOMEDS::SComponent_ptr theComponent, bool theRestore)
 Set/Get flag to restore or not path in paraview state file.
bool GetRestoreParam (SALOMEDS::SComponent_ptr theComponent)
PARAVIS_Gen_iGetParavisGen (const CAM_Module *theModule)
 _PTR (Study) GetCStudy(const CAM_Module *theModule)

Detailed Description

The main package of interfaces of the module PARAVIS.

Definition of events.

Definition of collection classes for PARAVIS module.


Typedef Documentation

typedef sequence<char> PARAVIS::char_array

Definition at line 42 of file PARAVIS_Gen_Types.idl.

typedef sequence<double> PARAVIS::double_array

Definition at line 41 of file PARAVIS_Gen_Types.idl.

typedef sequence<float> PARAVIS::float_array

Definition at line 40 of file PARAVIS_Gen_Types.idl.

typedef string PARAVIS::function

Definition at line 36 of file PARAVIS_Gen_Types.idl.

typedef sequence<long> PARAVIS::long_array

Definition at line 39 of file PARAVIS_Gen_Types.idl.

typedef sequence<short> PARAVIS::short_array

Definition at line 38 of file PARAVIS_Gen_Types.idl.

typedef sequence<string> PARAVIS::string_array

Definition at line 37 of file PARAVIS_Gen_Types.idl.


Function Documentation

PARAVIS::_PTR ( Study  ) const

Definition at line 53 of file PVGUI_Tools.cxx.

  {
    if (theModule && theModule->application()) {
      SalomeApp_Study* activeStudy = 
       dynamic_cast<SalomeApp_Study*>(theModule->application()->activeStudy());
      if (activeStudy) {
       return activeStudy->studyDS();
      }
    }
    
    return _PTR(Study)();
  }

Here is the caller graph for this function:

const char * PARAVIS::checkNullStr ( const char *  theStr)

Definition at line 85 of file PARAVIS_Gen_i.cc.

  {
    if (strcmp(theStr, "NULL") == 0)
      return NULL;
    else
      return theStr;
  }
SALOMEDS::SComponent_var PARAVIS::FindOrCreateParaVisComponent ( SALOMEDS::Study_ptr  theStudyDocument)

Definition at line 52 of file PV_Tools.cxx.

  {
    SALOMEDS::SComponent_var aSComponent = theStudyDocument->FindComponent("PARAVIS");
    if (aSComponent->_is_nil()) {
      SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder();
      aStudyBuilder->NewCommand();
      int aLocked = theStudyDocument->GetProperties()->IsLocked();
      if (aLocked) theStudyDocument->GetProperties()->SetLocked(false);
      aSComponent = aStudyBuilder->NewComponent("PARAVIS");
      SALOMEDS::GenericAttribute_var anAttr = 
        aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeName");
      SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
      
      CORBA::ORB_var anORB = PARAVIS_Gen_i::GetORB();
      SALOME_NamingService *NamingService = new SALOME_NamingService( anORB );
      CORBA::Object_var objVarN = NamingService->Resolve("/Kernel/ModulCatalog");
      SALOME_ModuleCatalog::ModuleCatalog_var Catalogue  = 
        SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
      SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent( "PARAVIS" );
      if ( !CORBA::is_nil(Comp) ) {
        aName->SetValue( Comp->componentusername() );
      }
      
      anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributePixMap");
      SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
      aPixmap->SetPixMap( "pqAppIcon16.png" );

      // Create Attribute parameters for future using
      anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeParameter");
      
      PARAVIS_Gen_var aParaVisGen = PARAVIS_Gen_i::GetParavisGenImpl()->_this();
      aStudyBuilder->DefineComponentInstance(aSComponent, aParaVisGen);
      if (aLocked) 
        theStudyDocument->GetProperties()->SetLocked(true);
      aStudyBuilder->CommitCommand();
    }
    return aSComponent;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

PARAVIS_Base_i * PARAVIS::GET_SERVANT ( CORBA::Object_ptr  aObj)

Definition at line 91 of file PV_Tools.cxx.

                                                    {
    //dynamic_cast<PARAVIS_Base_i*>(PARAVIS_Gen_i::GetPOA()->reference_to_servant(OBJ).in())
    if (CORBA::is_nil(aObj))
      return NULL;
    try {
      PortableServer::POA_ptr aPOA = PARAVIS_Gen_i::GetPOA();
      PortableServer::ServantBase_var aServant = aPOA->reference_to_servant(aObj);
      return dynamic_cast<PARAVIS_Base_i*>(aServant.in());
    } catch (...) {
      MESSAGE("GET_SERVANT: Unknown exception!!!");
    }
    return NULL;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

QStringList PARAVIS::getAllSavedStates ( SALOMEDS::SComponent_ptr  theComponent,
QString  theNewPath = QString() 
)

Definition at line 330 of file PARAVIS_Gen_i.cc.

  {
    QStringList aStateFiles;

    if (!CORBA::is_nil(theComponent)) {
      SALOMEDS::Study_var aStudy = theComponent->GetStudy();
      SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent);
      for (; anIter->More(); anIter->Next()) {
       SALOMEDS::SObject_var aSObj = anIter->Value();
       SALOMEDS::GenericAttribute_var anAttr;
       if (!aSObj->FindAttribute(anAttr, "AttributeLocalID")) {
         continue;
       }
       SALOMEDS::AttributeLocalID_var anID = SALOMEDS::AttributeLocalID::_narrow(anAttr);
       if (!anID->Value() == PVSTATEID) {
         continue;
       }
       if (aSObj->FindAttribute(anAttr, "AttributeString")) {
         SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
         QString aStateFile(aStringAttr->Value());
         printf("getAllSavedStates, aStateFile = %s\n", aStateFile.toLatin1().constData());
         // Replace the old path with the new one
         if (!theNewPath.isEmpty()) {
           QFileInfo aFileInfo(aStateFile);
           QString aPath = aFileInfo.path();
           aStateFile.replace(aPath, theNewPath);
           aStringAttr->SetValue(aStateFile.toLatin1().constData());
           
           printf("getAllSavedStates, aStateFile NEW = %s\n", aStateFile.toLatin1().constData());
         }
         aStateFiles<<aStateFile;
       }
      }
    }

    return aStateFiles;
  }

Here is the caller graph for this function:

SALOMEDS::ListOfFileNames * PARAVIS::GetListOfFileNames ( const QStringList &  theFileNames)

Definition at line 37 of file PV_Tools.cxx.

  {
    SALOMEDS::ListOfFileNames_var aListOfFileNames = new SALOMEDS::ListOfFileNames;
    if(!theFileNames.isEmpty()){
      aListOfFileNames->length(theFileNames.size());
      int i = 0;
      foreach (QString aName, theFileNames) {
        aListOfFileNames[i] = qPrintable(aName);
        i++;
      }
    }
    return aListOfFileNames._retn();
  }

Here is the caller graph for this function:

PARAVIS_Gen_i * PARAVIS::GetParavisGen ( const CAM_Module *  theModule)

Definition at line 36 of file PVGUI_Tools.cxx.

  {
    static PARAVIS_Gen_i* aGen = NULL;
    if(!aGen){
      SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
      Engines::EngineComponent_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","PARAVIS");
      PARAVIS_Gen_var aPARAVIS = PARAVIS_Gen::_narrow(aComponent);
      if(!CORBA::is_nil(aPARAVIS)){
        aGen = PARAVIS_Gen_i::GetParavisGenImpl();
      }
    }
    if(!aGen)
      throw std::runtime_error("Can not create PARAVIS_Gen");
    return aGen;
  }

Here is the caller graph for this function:

bool PARAVIS::GetRestoreParam ( SALOMEDS::SComponent_ptr  theComponent)

Definition at line 114 of file PV_Tools.cxx.

  {
    SALOMEDS::GenericAttribute_var anAttr;
    if (theComponent->FindAttribute(anAttr, "AttributeParameter")) {
      SALOMEDS::AttributeParameter_var aParams = SALOMEDS::AttributeParameter::_narrow(anAttr);
      if (aParams->IsSet("RestorePath", 2)) {
        return aParams->GetBool("RestorePath");
      }
    }
    return true;
  }

Here is the caller graph for this function:

bool PARAVIS::LoadState ( SalomeApp_Application *  theApp,
SALOMEDS::SComponent_ptr  theComponent,
const SALOMEDS::TMPFile &  theStream,
const char *  theURL,
bool  isMultiFile 
)

Definition at line 479 of file PARAVIS_Gen_i.cc.

  {
    std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
    if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::Load - "<<aTmpDir);

    SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false);
    if (aSeq->length() == 0)
      return false;

    bool aRestore = GetRestoreParam(theComponent);
    MESSAGE("PARAVIS_Gen_i::Restore path - "<<aRestore);

    // Process main state
    std::string aFile = aTmpDir + std::string(aSeq[aSeq->length() - 1]);
    QStringList aEmptyList;
    processAllFilesInState(aFile.c_str(), aEmptyList, aTmpDir.c_str(), aRestore);
    ProcessVoidEvent(new TLoadStateFile(theApp, aFile.c_str()));

    // Process saved states
    QStringList aSavedStates = getAllSavedStates(theComponent, QString(aTmpDir.c_str()));
    foreach(QString aState, aSavedStates) {
      processAllFilesInState(aState.toLatin1().constData(), 
                          aEmptyList, aTmpDir.c_str(), aRestore);
    }
    
    return true;
  }

Here is the call graph for this function:

bool PARAVIS::processAllFilesInState ( const char *  aFileName,
QStringList &  theFileNames,
const char *  theNewPath,
bool  theRestore = false 
)

Definition at line 284 of file PARAVIS_Gen_i.cc.

  {
    QFile aFile(aFileName);
    if (!aFile.open(QFile::ReadOnly)) {
      MESSAGE("Can't open state file "<<aFileName);
      return false;
    }
    QDomDocument aDoc;
    bool aRes = aDoc.setContent(&aFile);
    aFile.close();
    
    if (!aRes) {
      MESSAGE("File "<<aFileName<<" is not XML document");
      return false;
    }
    
    QDomElement aRoot = aDoc.documentElement();
    if ( aRoot.isNull() ) {
      MESSAGE( "Invalid XML root" );
      return false;
    }

    QDomNode aNode = aRoot.firstChild();
    while (aRes  && !aNode.isNull() ) {
      aRes = aNode.isElement();
      if ( aRes ) {
        QDomElement aSection = aNode.toElement();
        if (aSection.tagName() == "ServerManagerState") {
          processProxies(aNode, theFileNames, theNewPath, theRestore);
        }
      }
      aNode = aNode.nextSibling();
    }
    if (!aFile.open(QFile::WriteOnly | QFile::Truncate)) {
      MESSAGE("Can't open state file "<<aFileName<<" for writing");
      return false;
    }
    QTextStream out(&aFile);
    aDoc.save(out, 2);
    aFile.close();
    
    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void PARAVIS::processElements ( QDomNode &  thePropertyNode,
QStringList &  theFileNames,
const char *  theNewPath,
bool  theRestore 
)

Definition at line 223 of file PARAVIS_Gen_i.cc.

  {
    QDomNode aElementNode = thePropertyNode.firstChild();
    while (aElementNode.isElement()) {
      QDomElement aElement = aElementNode.toElement();
      if (aElement.tagName() == "Element") {
        QString aIndex = aElement.attribute("index");
        if (aIndex == "0") {
          QString aValue = aElement.attribute("value");
          if (!aValue.isNull()) {
            if (!theNewPath) {
              QFileInfo aFInfo(aValue);
              if (aFInfo.exists()) {
                theFileNames<<aValue;
                aElement.setAttribute("value", aFInfo.fileName());
              }
              break;
            } else {
              if (theRestore)
                aElement.setAttribute("value", QString(theNewPath) + aValue);
            }
          }
        }
      }
      aElementNode = aElementNode.nextSibling();
    }
  }

Here is the caller graph for this function:

void PARAVIS::processProperties ( QDomNode &  theProxyNode,
QStringList &  theFileNames,
const char *  theNewPath,
bool  theRestore 
)

Definition at line 253 of file PARAVIS_Gen_i.cc.

  {
    QDomNode aPropertyNode = theProxyNode.firstChild();
    while (aPropertyNode.isElement()) {
      QDomElement aProperty = aPropertyNode.toElement();
      QString aName = aProperty.attribute("name");
      if ((aName == "FileName") || (aName == "FileNameInfo") || (aName == "FileNames")) {
        processElements(aPropertyNode, theFileNames, theNewPath, theRestore);
      }
      aPropertyNode = aPropertyNode.nextSibling();
    }
  }  

Here is the call graph for this function:

Here is the caller graph for this function:

void PARAVIS::processProxies ( QDomNode &  theNode,
QStringList &  theFileNames,
const char *  theNewPath,
bool  theRestore 
)

Definition at line 268 of file PARAVIS_Gen_i.cc.

  {
    QDomNode aProxyNode = theNode.firstChild();
    while (aProxyNode.isElement()) {
      QDomElement aProxy = aProxyNode.toElement();
      if (aProxy.tagName() == "Proxy") {
        QString aGroup = aProxy.attribute("group");
        if (aGroup == "sources") {
          processProperties(aProxyNode, theFileNames, theNewPath, theRestore);
        }
      }
      aProxyNode = aProxyNode.nextSibling();
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

SALOMEDS::TMPFile* PARAVIS::SaveState ( long  thePID,
SalomeApp_Application *  theApp,
SALOMEDS::SComponent_ptr  theComponent,
const char *  theURL,
bool  isMultiFile 
)

Definition at line 369 of file PARAVIS_Gen_i.cc.

  {
    std::string aTmpDir = SALOMEDS_Tool::GetTmpDir();

    std::ostringstream aStream;
    aStream<<"paravisstate:"<<thePID;
    std::string aFileName = "_" + aStream.str();
    if(MYDEBUG) MESSAGE("aFileName = '"<<aFileName);

    SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);

    std::string aFile = aTmpDir + aFileName;
    ProcessVoidEvent(new TSaveStateFile(theApp, aFile.c_str()));

    // Get saved states
    QStringList aSavedStates = getAllSavedStates(theComponent);

    // Collect all files from state
    SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
    int aSavingType = aResourceMgr->integerValue( "PARAVIS", "savestate_type", 0 );

    QStringList aFileNames;
    QStringList aNames;
   
    switch (aSavingType) {
    case 0: // Save referenced files only for builin server
      {
        MESSAGE("Save as built in;")
        bool aIsBuiltIn = true;
        pqServer* aServer = ProcessEvent(new TGetActiveServer(theApp));
        if (aServer) 
          aIsBuiltIn != aServer->isRemote();
      
        if (aIsBuiltIn)
        {
         // Find referenced files and collect their paths nullyfying references:
         
         // for saved states
         foreach (QString aState, aSavedStates) {
           processAllFilesInState(aState.toLatin1().constData(), aFileNames, 0);
         }

         // for main state
          processAllFilesInState(aFile.c_str(), aFileNames, 0); 

          SetRestoreParam(theComponent, true);
        } else {
          SetRestoreParam(theComponent, false);
       }
      }
      break;
    case 1: //Save referenced files when they are accessible
      {
        // Find referenced files and collect their paths nullyfying references

       // for saved states
       foreach (QString aState, aSavedStates) {
         processAllFilesInState(aState.toLatin1().constData(), aFileNames, 0);
       }
       
       // for main state
        processAllFilesInState(aFile.c_str(), aFileNames, 0);
        SetRestoreParam(theComponent, true);
      }
      break;
    case 2: //Never save referenced files
      SetRestoreParam(theComponent, false);
      break;
    }

    // Add saved states
    foreach (QString aSavedState, aSavedStates) {
      aFileNames<<aSavedState;
    }

    // Add main state to the end of the list
    aFileNames<<QString(aFile.c_str());

    // File names for main state and its data files
    foreach(QString aFile, aFileNames) {
      QFileInfo aInfo(aFile);
      aNames<<aInfo.fileName();
    }
    SALOMEDS::ListOfFileNames_var aListOfFileNames = GetListOfFileNames(aFileNames);
    SALOMEDS::ListOfFileNames_var aListOfNames = GetListOfFileNames(aNames);

    aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFileNames.in(), aListOfNames.in());
    
    return aStreamFile._retn();
  }

Here is the call graph for this function:

void PARAVIS::SetRestoreParam ( SALOMEDS::SComponent_ptr  theComponent,
bool  theRestore 
)

Set/Get flag to restore or not path in paraview state file.

Definition at line 105 of file PV_Tools.cxx.

  {
    SALOMEDS::GenericAttribute_var anAttr;
    if (theComponent->FindAttribute(anAttr, "AttributeParameter")) {
      SALOMEDS::AttributeParameter_var aParams = SALOMEDS::AttributeParameter::_narrow(anAttr);
      aParams->SetBool("RestorePath", theRestore);
    }
  }

Here is the caller graph for this function:

std::string PARAVIS::tabify ( const std::string &  source,
bool  isTabify 
)

Definition at line 93 of file PARAVIS_Gen_i.cc.

  {
    std::string result = source;
    if ( isTabify && !result.empty() ) {
      std::string caret = "\n";
      int idx = result.rfind( caret );
      while ( idx != std::string::npos ) {
       result.replace( idx, caret.size(), "\n\t" );
       idx = result.rfind( caret, idx-1 );
      }
      result.insert(0, "\t" );
    }
    return result;
  }

Here is the caller graph for this function: