]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Merging from branch For_CTH_V12
authorouv <ouv@opencascade.com>
Mon, 8 Sep 2008 13:22:37 +0000 (13:22 +0000)
committerouv <ouv@opencascade.com>
Mon, 8 Sep 2008 13:22:37 +0000 (13:22 +0000)
27 files changed:
src/DDS/DDS_DicGroup.cxx
src/DDS/DDS_DicItem.cxx
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Dialog.cxx
src/LightApp/LightApp_Driver.cxx
src/LightApp/LightApp_Driver.h
src/LightApp/LightApp_HDFDriver.cxx
src/LightApp/LightApp_Module.cxx
src/LightApp/LightApp_Module.h
src/LightApp/LightApp_VTKSelector.cxx
src/LightApp/LightApp_VTKSelector.h
src/Qtx/QtxWorkstack.cxx
src/STD/STD_Application.cxx
src/SUIT/SUIT_DataBrowser.cxx
src/SUIT/SUIT_DataBrowser.h
src/SUIT/SUIT_FileDlg.cxx
src/SUIT/SUIT_FileDlg.h
src/SUIT/SUIT_ViewManager.cxx
src/SVTK/SALOME_Actor.cxx
src/SVTK/SALOME_Actor.h
src/SVTK/SVTK_Actor.cxx
src/SVTK/SVTK_DeviceActor.cxx
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_RectPicker.cxx
src/SVTK/SVTK_RectPicker.h
src/SVTK/SVTK_RenderWindowInteractor.cxx
src/SVTK/SVTK_ViewModel.cxx

index 3bb337ad38d1d878432305557be777ca10125edf..a93416dfc5613faea2b5dfcdb1a48f8ff07578ae 100644 (file)
@@ -30,6 +30,8 @@
 #include <Standard_Failure.hxx>
 #include <Standard_ErrorHandler.hxx>
 
+#include <stdio.h>
+
 IMPLEMENT_STANDARD_HANDLE(DDS_DicGroup, MMgt_TShared)
 IMPLEMENT_STANDARD_RTTIEXT(DDS_DicGroup, MMgt_TShared)
 
index 12a9427050a7e35a32fdb1fc6a07334604d40dee..86e062bf47170cc7a33e5f210984226dea0508db 100644 (file)
@@ -32,6 +32,8 @@
 #include <TColStd_MapOfReal.hxx>
 #include <TColStd_SequenceOfAsciiString.hxx>
 
+#include <stdio.h>
+
 IMPLEMENT_STANDARD_HANDLE(DDS_DicItem, MMgt_TShared)
 IMPLEMENT_STANDARD_RTTIEXT(DDS_DicItem, MMgt_TShared)
 
index fd22e1e9bf14eed057731dd3382a96a6bc97a550..47bbb1290b46435d7ff09e21797fb5c0d57d4129 100644 (file)
@@ -662,7 +662,7 @@ QString LightApp_Application::defaultModule() const
   modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
   //! If there's the one and only module --> activate it automatically
   //! TODO: Possible improvement - default module can be taken from preferences
-  return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
+  return aModuleNames.count() > 1 ? QString( "" ) : ( aModuleNames.count() ? aModuleNames.first() : QString( "" ) );
 }
 
 /*!On new window slot.*/
@@ -2225,6 +2225,13 @@ void LightApp_Application::updateDesktopTitle()
     aTitle += QString( " - [%1]" ).arg( sName );
   }
 
+  QStringList anInfoList;
+  modules( anInfoList, false );
+
+  LightApp_Module* aModule = ( LightApp_Module* )activeModule();
+  if( aModule && anInfoList.count() == 1 ) // to avoid a conflict between different modules
+    aTitle = aModule->updateDesktopTitle( aTitle );
+
   desktop()->setWindowTitle( aTitle );
 }
 
@@ -2836,7 +2843,7 @@ bool LightApp_Application::event( QEvent* e )
     SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
     QString* d = ( QString* )ce->data();
     if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
-                                 d ? *d : "",
+                                 d ? *d : QString( "" ),
                                  SUIT_MessageBox::Yes | SUIT_MessageBox::No,
                                  SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
        onPreferences();
index 049dc244c8901153511d7b5b7a408830eba1f7d4..8ad4dff9b8a7c5d3ca0cf37a21077b67b0628fb3 100644 (file)
@@ -269,7 +269,7 @@ QWidget* LightApp_Dialog::objectWg( const int theId, const int theWgId ) const
 */
 QString LightApp_Dialog::objectText( const int theId ) const
 {
-  return myObjects.contains( theId ) ? myObjects[ theId ].myEdit->text() : "";
+  return myObjects.contains( theId ) ? myObjects[ theId ].myEdit->text() : QString( "" );
 }
 
 /*!
index 08c1d2cdf6677c32a9467fda268e924fc00cbc74..08b791f6611d00c1175779b09e5e4da7dcea42cc 100644 (file)
 
 /*! Constructor.*/
 LightApp_Driver::LightApp_Driver()
-: myIsTemp( false )
+: myIsTemp( false ),
+  myCurrPos( 0 ),
+  myCurrBuff( 0 ),
+  myCurrFileIndex( 0 ),
+  myCurrIFile( 0 ), 
+  mySizeToBeWritten( 0 ),
+  myFileSizes( 0 ),
+  myFileNameSizes( 0 ),
+  myCurrOFile( 0 ),
+  myNbFilles( 0 )
 {
 }
  
 /*! Destructor.*/
 LightApp_Driver::~LightApp_Driver()
 {
+  delete myFileSizes;
+  delete myFileNameSizes;
 }
 
 using namespace std;
@@ -70,7 +81,7 @@ bool LightApp_Driver::SaveDatasInFile( const char* theFileName, bool isMultiFile
     aFileBufferSize += 4;                                //Add 4 bytes: a length of the module name
     aFileBufferSize += strlen(aModuleName[i])+1;
     std::string aName(aModuleName[i]);
-    PutFilesToStream(aName, aBuffer[i], aBufferSize[i], isMultiFile);
+    //PutFilesToStream(aName, aBuffer[i], aBufferSize[i], isMultiFile);
     aFileBufferSize += 8;                                //Add 8 bytes: a length of the buffer
     aFileBufferSize += aBufferSize[i];
     i++;
@@ -176,7 +187,8 @@ bool LightApp_Driver::ReadDatasFromFile( const char* theFileName, bool isMultiFi
     aCurrentPos += aBufferSize;
 
     // Put buffer to aListOfFiles and set to myMap
-    ListOfFiles aListOfFiles = PutStreamToFiles(aBuffer, aBufferSize, isMultiFile);
+    //ListOfFiles aListOfFiles = PutStreamToFiles(aBuffer, aBufferSize, isMultiFile);
+    ListOfFiles aListOfFiles;
     SetListOfFiles(aModuleName, aListOfFiles);
 
     delete[] aModuleName;
@@ -222,180 +234,6 @@ void LightApp_Driver::SetListOfFiles( const char* theModuleName, const ListOfFil
   myMap[aName] = theListOfFiles;
 }
 
-/*!
-  Converts files which was created from module <theModuleName> into a byte sequence unsigned char
-*/
-void LightApp_Driver::PutFilesToStream( const std::string& theModuleName, unsigned char*& theBuffer,
-                                        long& theBufferSize, bool theNamesOnly )
-{
-  ListOfFiles aFiles = myMap[theModuleName];
-  // aFiles must contain temporary directory name in its first item
-  // and names of files (relatively the temporary directory) in the others
-
-  int i, aLength = aFiles.size() - 1;
-  if(aLength <= 0) {
-    theBufferSize = 0;
-    theBuffer = new unsigned char[theBufferSize];
-    return;
-  }
-  //Get a temporary directory for saved a file
-  TCollection_AsciiString aTmpDir(const_cast<char*>(aFiles[0].c_str()));
-
-  long aBufferSize = 0;
-  long aCurrentPos;
-  int aNbFiles = 0;
-  int* aFileNameSize= new int[aLength];
-  long* aFileSize= new long[aLength];
-
-  //Determine the required size of the buffer
-  TCollection_AsciiString aFileName;
-  for (i = 0; i < aLength; i++) {
-    char* aFName = const_cast<char*>(aFiles[i+1].c_str());
-    aFileName = aFName;
-    //Check if the file exists
-    if (!theNamesOnly) { // mpv 15.01.2003: if only file names must be stroed, then size of files is zero
-      TCollection_AsciiString aFullPath = aTmpDir + aFileName;   
-      OSD_Path anOSDPath(aFullPath);
-      OSD_File anOSDFile(anOSDPath);
-      if(!anOSDFile.Exists()) continue;
-#ifdef WIN32
-      ifstream aFile(aFullPath.ToCString(), ios::binary);
-#else
-      ifstream aFile(aFullPath.ToCString());
-#endif
-      aFile.seekg(0, ios::end);
-      aFileSize[i] = aFile.tellg();
-      aBufferSize += aFileSize[i];              //Add a space to store the file
-    }
-    aFileNameSize[i] = strlen(aFName) + 1;
-    aBufferSize += aFileNameSize[i];          //Add a space to store the file name
-    aBufferSize += (theNamesOnly)?4:12;       //Add 4 bytes: a length of the file name,
-                                              //    8 bytes: length of the file itself
-    aNbFiles++;
-  }
-
-  aBufferSize += 4;      //4 bytes for a number of the files that will be written to the stream;
-  theBuffer = new unsigned char[aBufferSize];  
-  if(theBuffer == NULL) {
-    theBufferSize = 0;
-    theBuffer = 0;
-    return;
-  }
-  //Initialize 4 bytes of the buffer by 0
-  memset(theBuffer, 0, 4); 
-  //Copy the number of files that will be written to the stream
-  memcpy(theBuffer, &aNbFiles, ((sizeof(int) > 4) ? 4 : sizeof(int))); 
-
-  aCurrentPos = 4;
-
-  for(i = 0; i < aLength; i++) {
-    ifstream *aFile;
-    if (!theNamesOnly) { // mpv 15.01.2003: we don't open any file if theNamesOnly = true
-      TCollection_AsciiString aName(const_cast<char*>(aFiles[i+1].c_str()));
-      TCollection_AsciiString aFullPath = aTmpDir + aName;
-      OSD_Path anOSDPath(aFullPath);
-      OSD_File anOSDFile(anOSDPath);
-      if(!anOSDFile.Exists()) continue;
-#ifdef WIN32
-      aFile = new ifstream(aFullPath.ToCString(), ios::binary);
-#else
-      aFile = new ifstream(aFullPath.ToCString());
-#endif
-    }
-    //Initialize 4 bytes of the buffer by 0
-    memset((theBuffer + aCurrentPos), 0, 4); 
-    //Copy the length of the file name to the buffer
-    memcpy((theBuffer + aCurrentPos), (aFileNameSize + i), ((sizeof(int) > 4) ? 4 : sizeof(int))); 
-    aCurrentPos += 4;
-
-    //Copy the file name to the buffer
-    char* aFName = const_cast<char*>(aFiles[i+1].c_str());
-    memcpy((theBuffer + aCurrentPos), aFName, aFileNameSize[i]);
-    aCurrentPos += aFileNameSize[i];
-    
-    if (!theNamesOnly) { // mpv 15.01.2003: we don't copy file content to the buffer if !theNamesOnly
-      //Initialize 8 bytes of the buffer by 0
-      memset((theBuffer + aCurrentPos), 0, 8); 
-      //Copy the length of the file to the buffer
-      memcpy((theBuffer + aCurrentPos), (aFileSize + i), ((sizeof(long) > 8) ? 8 : sizeof(long)));
-      aCurrentPos += 8;
-      
-      aFile->seekg(0, ios::beg);
-      aFile->read((char *)(theBuffer + aCurrentPos), aFileSize[i]);
-      aFile->close();
-      delete(aFile);
-      aCurrentPos += aFileSize[i];
-    }
-  }
-  delete[] aFileNameSize;
-  delete[] aFileSize;
-
-  theBufferSize = aBufferSize;
-}
-
-/*!
-  Converts a byte sequence <theBuffer> to files and return list of them
-*/
-LightApp_Driver::ListOfFiles LightApp_Driver::PutStreamToFiles( const unsigned char* theBuffer,
-                                                                const long theBufferSize, bool theNamesOnly )
-{
-  if(theBufferSize == 0 || theBuffer == 0)
-    return   ListOfFiles();
-
-  // Create a temporary directory for the component's data files
-  std::string aDir = GetTmpDir();
-
-  // Remember that the files are in a temporary location that should be deleted
-  // when a study is closed
-  SetIsTemporary( true );
-
-  //Get a temporary directory for saving a file
-  TCollection_AsciiString aTmpDir(const_cast<char*>(aDir.c_str()));
-
-  long aFileSize, aCurrentPos = 4;
-  int i, aFileNameSize, aNbFiles = 0;
-
-  //Copy the number of files in the stream
-  memcpy(&aNbFiles, theBuffer, sizeof(int)); 
-
-  const int n = aNbFiles + 1;
-  ListOfFiles aFiles(n);
-  aFiles[0] = aDir;
-
-  for(i = 0; i < aNbFiles; i++) {
-    //Put a length of the file name to aFileNameSize
-    memcpy(&aFileNameSize, (theBuffer + aCurrentPos), ((sizeof(int) > 4) ? 4 : sizeof(int))); 
-    aCurrentPos += 4;
-
-    char *aFileName = new char[aFileNameSize];
-    //Put a file name to aFileName
-    memcpy(aFileName, (theBuffer + aCurrentPos), aFileNameSize); 
-    aCurrentPos += aFileNameSize;
-    //Put a length of the file to aFileSize
-    if (!theNamesOnly) {
-      memcpy(&aFileSize, (theBuffer + aCurrentPos), ((sizeof(long) > 8) ? 8 : sizeof(long)));
-      aCurrentPos += 8;    
-      
-      TCollection_AsciiString aFullPath = aTmpDir + aFileName;
-      
-#ifdef WIN32
-  ofstream aFile(aFullPath.ToCString(), ios::out | ios::binary);
-#else
-  ofstream aFile(aFullPath.ToCString());
-#endif
-
-      aFile.write((char *)(theBuffer+aCurrentPos), aFileSize); 
-      aFile.close();  
-      aCurrentPos += aFileSize;
-    }
-    std::string aStrFileName(aFileName);
-    aFiles[i+1] = aStrFileName;
-    delete[] aFileName;
-  }
-  return aFiles;
-}
-
 /*!
   Remove files. First item in <theFiles> is a directory with slash at the end.
   Other items are names of files. If <IsDirDeleted> is true,
@@ -550,3 +388,462 @@ std::string LightApp_Driver::GetDirFromPath( const std::string& thePath ) {
   return aDirString.ToCString();
 }
 
+//=============================================================================
+// Function : PutFilesToFirstStream
+// Purpose  : 
+//=============================================================================
+bool LightApp_Driver::PutFilesToFirstStream( const std::string& theModuleName, unsigned char*& theBuffer,
+                                             long& theBufferSize, bool theNamesOnly )
+{
+  myCurrPos = 0;
+  myCurrBuff = 0;
+  myCurrFileIndex = 0;
+  myCurrIFile = 0;
+  mySizeToBeWritten = 0;
+  if ( myFileSizes )
+  {
+    delete[] myFileSizes;
+    myFileSizes = 0;
+  }
+  if ( myFileNameSizes )
+  {
+    delete[] myFileNameSizes;
+    myFileNameSizes = 0;
+  }
+
+  ListOfFiles aFiles = myMap[theModuleName];
+  // aFiles must contain temporary directory name in its first item
+  // and names of files (relatively the temporary directory) in the others
+
+  int i, aLength = aFiles.size() - 1;
+  if(aLength <= 0) {
+     theBufferSize = 0;
+     theBuffer = new unsigned char[theBufferSize];
+    return true;
+  }
+  //Get a temporary directory for saved a file
+  TCollection_AsciiString aTmpDir(const_cast<char*>(aFiles[0].c_str()));
+
+  int aNbFiles = 0;
+  myFileNameSizes = new size_t[aLength];
+  myFileSizes = new size_t[aLength];
+
+  //Determine the required size of the buffer
+  TCollection_AsciiString aFileName;
+  for (i = 0; i < aLength; i++) 
+  {
+    char* aFName = const_cast<char*>(aFiles[i+1].c_str());
+    aFileName = aFName;
+    //Check if the file exists
+    if (!theNamesOnly) 
+    { 
+      TCollection_AsciiString aFullPath = aTmpDir + aFileName;   
+      OSD_Path anOSDPath(aFullPath);
+      OSD_File anOSDFile(anOSDPath);
+      if(!anOSDFile.Exists()) 
+        continue;
+#ifdef WNT
+      ifstream aFile(aFullPath.ToCString(), ios::binary);
+#else
+      ifstream aFile(aFullPath.ToCString());
+#endif
+      aFile.seekg(0, ios::end);
+      myFileSizes[i] = aFile.tellg();
+      mySizeToBeWritten += myFileSizes[i];              //Add a space to store the file
+    }
+    myFileNameSizes[i] = strlen(aFName) + 1;
+    mySizeToBeWritten += myFileNameSizes[i];          //Add a space to store the file name
+    mySizeToBeWritten += (theNamesOnly)?4:12;       //Add 4 bytes: a length of the file name,
+                                              //    8 bytes: length of the file itself
+    aNbFiles++;
+  }
+
+  mySizeToBeWritten += 4;      //4 bytes for a number of the files that will be written to the stream;
+
+  size_t aCurrSize = mySizeToBeWritten <= GetMaxBuffSize() ? mySizeToBeWritten : GetMaxBuffSize();
+  theBuffer = new unsigned char[ aCurrSize ];
+  myCurrBuff = theBuffer;
+
+  //Initialize 4 bytes of the buffer by 0
+  memset( theBuffer, 0, 4); 
+  //Copy the number of files that will be written to the stream
+  memcpy( theBuffer, &aNbFiles, ((sizeof(int) > 4) ? 4 : sizeof(int))); 
+
+  myCurrPos = 4;
+  int aCurrnetBuff = 0;
+
+  for ( myCurrFileIndex = 0; myCurrFileIndex < aLength; myCurrFileIndex++ ) 
+  {
+    if (!theNamesOnly) 
+    { // mpv 15.01.2003: we don't open any file if theNamesOnly = true
+      TCollection_AsciiString aName(const_cast<char*>(aFiles[myCurrFileIndex+1].c_str()));
+      TCollection_AsciiString aFullPath = aTmpDir + aName;
+      OSD_Path anOSDPath(aFullPath);
+      OSD_File anOSDFile(anOSDPath);
+      if(!anOSDFile.Exists()) continue;
+#ifdef WNT
+      myCurrIFile = new ifstream(aFullPath.ToCString(), ios::binary);
+#else
+      myCurrIFile = new ifstream(aFullPath.ToCString());
+#endif
+    }
+    
+    //Initialize 4 bytes of the buffer by 0
+    memset( (theBuffer + myCurrPos), 0, 4); 
+        
+    //Copy the length of the file name to the buffer
+    memcpy((theBuffer + myCurrPos), (myFileNameSizes + myCurrFileIndex), ((sizeof(int) > 4) ? 4 : sizeof(int))); 
+    myCurrPos += 4;
+    
+    //Copy the file name to the buffer
+    char* aFName = const_cast<char*>(aFiles[myCurrFileIndex+1].c_str());
+    memcpy( myCurrBuff + myCurrPos, aFName, myFileNameSizes[ myCurrFileIndex ] );
+    myCurrPos += myFileNameSizes[myCurrFileIndex];
+    
+    if (!theNamesOnly) // mpv 15.01.2003: we don't copy file content to the buffer if !theNamesOnly
+    { 
+      //Initialize 8 bytes of the buffer by 0
+      memset( myCurrBuff + myCurrPos, 0, 8 ); 
+
+      //Copy the length of the file to the buffer
+      memcpy( myCurrBuff + myCurrPos,  
+              (unsigned char*)(myFileSizes + myCurrFileIndex), ((sizeof(long) > 8) ? 8 : sizeof(long)));
+      myCurrPos += 8;
+      
+      // old code for small files
+      if ( aCurrSize < GetMaxBuffSize() )
+      {
+        myCurrIFile->seekg(0, ios::beg);
+        myCurrIFile->read((char *)(theBuffer + myCurrPos), myFileSizes[myCurrFileIndex]);
+        myCurrIFile->close();
+        delete(myCurrIFile);
+        myCurrIFile = 0;
+        myCurrPos += myFileSizes[myCurrFileIndex];
+        mySizeToBeWritten = 0;
+      }
+      else // new code for big files
+      {
+        myCurrIFile->seekg(0, ios::beg);
+        int aPos = myCurrIFile->tellg();
+        size_t aSizeToRead = GetMaxBuffSize() - myCurrPos;
+        if ( aSizeToRead > myFileSizes[myCurrFileIndex] - myCurrIFile->tellg() )
+          aSizeToRead = myFileSizes[myCurrFileIndex] - myCurrIFile->tellg();
+        myCurrIFile->read((char *)(theBuffer + myCurrPos), aSizeToRead );
+        mySizeToBeWritten -= aSizeToRead - myCurrPos;
+        myCurrPos += aSizeToRead;
+        if ( myCurrPos == GetMaxBuffSize() )
+        {
+          myCurrPos = 0;
+          break;
+        }
+        else // file was saved complitelly
+        {
+          myCurrIFile->close();
+          delete(myCurrIFile);
+          myCurrIFile = 0;
+        }
+        if ( myCurrIFile )
+          aPos = myCurrIFile->tellg();
+      }
+    }
+  }
+  
+  if ( aCurrSize < GetMaxBuffSize() )
+    theBufferSize = myCurrPos;
+  else 
+    theBufferSize = GetMaxBuffSize();
+
+  return aCurrSize < GetMaxBuffSize();
+}
+
+//=============================================================================
+// Function : HasUnsavedData
+// Purpose  : 
+//=============================================================================
+bool LightApp_Driver::HasUnsavedData() const
+{
+  return myCurrIFile && mySizeToBeWritten;
+}
+
+//=============================================================================
+// Function : PutFilesToNextStream
+// Purpose  : 
+//=============================================================================
+bool LightApp_Driver::PutFilesToNextStream( const std::string& theModuleName, unsigned char*& theBuffer,
+                                            long& theBufferSize, bool theNamesOnly )
+{
+  if ( theNamesOnly || !HasUnsavedData() )
+    return true;
+
+  ListOfFiles aFiles = myMap[ theModuleName ];
+  int aLength = aFiles.size() - 1;
+  if ( aLength <= 0 )
+    return true;
+
+  TCollection_AsciiString aTmpDir(const_cast<char*>(aFiles[0].c_str()));
+
+  size_t aCurrSize = mySizeToBeWritten <= GetMaxBuffSize() ? mySizeToBeWritten : GetMaxBuffSize();
+
+  for ( ; myCurrFileIndex < aLength; myCurrFileIndex++ ) 
+  {
+    TCollection_AsciiString aName(const_cast<char*>(aFiles[myCurrFileIndex+1].c_str()));
+    TCollection_AsciiString aFullPath = aTmpDir + aName;
+    OSD_Path anOSDPath(aFullPath);
+    OSD_File anOSDFile(anOSDPath);
+    if(!anOSDFile.Exists()) 
+      continue;
+
+    if ( !myCurrIFile )
+    {
+#ifdef WNT
+      myCurrIFile = new ifstream( aFullPath.ToCString(), ios::binary );
+#else
+      myCurrIFile = new ifstream( aFullPath.ToCString() );
+#endif
+
+      myCurrIFile->seekg(0, ios::beg);
+
+      ////////////
+      //Initialize 4 bytes of the buffer by 0
+      memset( (myCurrBuff + myCurrPos), 0, 4); 
+      //Copy the length of the file name to the buffer
+      memcpy((myCurrBuff + myCurrPos), ( myFileNameSizes + myCurrFileIndex ), ((sizeof(int) > 4) ? 4 : sizeof(int))); 
+      myCurrPos += 4;
+
+      //Copy the file name to the buffer
+      char* aFName = const_cast<char*>(aFiles[myCurrFileIndex+1].c_str());
+      memcpy( myCurrBuff + myCurrPos, aFName, myFileNameSizes[ myCurrFileIndex ] );
+      myCurrPos += myFileNameSizes[myCurrFileIndex];
+      /////////////
+
+      //Initialize 8 bytes of the buffer by 0
+      memset( myCurrBuff + myCurrPos, 0, 8 ); 
+      
+      //Copy the length of the file to the buffer
+      memcpy( myCurrBuff + myCurrPos,  
+        (unsigned char*)(myFileSizes + myCurrFileIndex), ((sizeof(long) > 8) ? 8 : sizeof(long)));
+      myCurrPos += 8;
+    }
+
+    // old code for small files
+    if ( aCurrSize < GetMaxBuffSize() )
+    {
+      //myCurrIFile->seekg(0, ios::beg);
+      size_t aSizeToRead = myFileSizes[myCurrFileIndex] - myCurrIFile->tellg();
+      myCurrIFile->read((char *)(theBuffer + myCurrPos), aSizeToRead );
+      myCurrIFile->close();
+      delete(myCurrIFile);
+      myCurrIFile = 0;
+      myCurrPos += aSizeToRead;
+      mySizeToBeWritten = 0;
+    }
+    else // new code for big files
+    {
+      int aPos = myCurrIFile->tellg();
+      size_t aFileSize = myFileSizes[myCurrFileIndex];
+      size_t aSizeToRead = GetMaxBuffSize() - myCurrPos;
+      if ( aSizeToRead > myFileSizes[myCurrFileIndex] - myCurrIFile->tellg() )
+        aSizeToRead = myFileSizes[myCurrFileIndex] - myCurrIFile->tellg();
+      myCurrIFile->read((char *)(theBuffer + myCurrPos), aSizeToRead );
+      mySizeToBeWritten -= aSizeToRead - myCurrPos;
+      myCurrPos += aSizeToRead;
+      if ( myCurrPos == GetMaxBuffSize() )
+      {
+        myCurrPos = 0;
+        break;
+      }
+      else // file was saved complitelly
+      {
+        myCurrIFile->close();
+        delete(myCurrIFile);
+        myCurrIFile = 0;
+      }
+      if ( myCurrIFile )
+        aPos = myCurrIFile->tellg();
+    }
+  }
+  
+  if ( aCurrSize < GetMaxBuffSize() )
+    theBufferSize = myCurrPos - 1;
+  else 
+    theBufferSize = GetMaxBuffSize();
+
+  return aCurrSize < GetMaxBuffSize();
+}
+
+//=============================================================================
+// Function : PutFirstStreamToFiles
+// Purpose  : 
+//=============================================================================
+void LightApp_Driver::PutFirstStreamToFiles( ListOfFiles& theListOfFiles, 
+                                             const unsigned char* theBuffer,
+                                             const long theBufferSize, 
+                                             bool theNamesOnly )
+{
+  theListOfFiles.resize( 0 );
+  myCurrPos = 0;
+  myCurrOFile = 0;
+  mySizeToBeWritten = 0;
+
+  if ( theBufferSize == 0 || theBuffer == 0 )
+    return;
+
+  delete[] myFileSizes;
+  delete[] myFileNameSizes;
+
+  // Create a temporary directory for the component's data files
+  std::string aDir = GetTmpDir();
+
+  // Remember that the files are in a temporary location that should be deleted
+  // when a study is closed
+  SetIsTemporary( true );
+
+  //Get a temporary directory for saving a file
+  TCollection_AsciiString aTmpDir(const_cast<char*>(aDir.c_str()));
+
+  myCurrPos = 4;
+  
+  //Copy the number of files in the stream
+  memcpy(&myNbFilles, theBuffer, sizeof(int)); 
+
+  const int n = myNbFilles + 1;
+  theListOfFiles.resize( n );
+  myFileSizes = new size_t[ n ];
+  myFileNameSizes = new size_t[ n ];
+  theListOfFiles[ 0 ] = aDir;
+  myFileSizes[ 0 ] = 0;
+  myFileNameSizes[ 0 ] = 0;
+
+  for( myCurrFileIndex = 1; myCurrFileIndex <= myNbFilles; myCurrFileIndex++) 
+  {
+    //Put a length of the file name to myFileNameSizes[ myCurrFileIndex ]
+    memcpy(&myFileNameSizes[ myCurrFileIndex ], (theBuffer + myCurrPos), ((sizeof(int) > 4) ? 4 : sizeof(int))); 
+    myCurrPos += 4;
+
+    char *aFileName = new char[ myFileNameSizes[ myCurrFileIndex ] ];
+    //Put a file name to aFileName
+    memcpy(aFileName, (theBuffer + myCurrPos), myFileNameSizes[ myCurrFileIndex ]); 
+    myCurrPos += myFileNameSizes[ myCurrFileIndex ];
+    
+    //Put a length of the file to myFileSizes
+    if (!theNamesOnly) 
+    {
+      memcpy(&myFileSizes[ myCurrFileIndex ], (theBuffer + myCurrPos), ((sizeof(long) > 8) ? 8 : sizeof(long)));
+      myCurrPos += 8;    
+      
+      TCollection_AsciiString aFullPath = aTmpDir + aFileName;
+      
+#ifdef WNT  
+  myCurrOFile  = new ofstream(aFullPath.ToCString(), ios::out | ios::binary);
+#else
+  myCurrOFile  = new ofstream(aFullPath.ToCString());
+#endif
+      
+      std::string aStrFileName( aFileName );
+      theListOfFiles[ myCurrFileIndex ] = aStrFileName;
+      delete[] aFileName;
+
+      if ( myFileSizes[ myCurrFileIndex ] <= theBufferSize - myCurrPos )
+      {
+        // old code 
+        myCurrOFile->write((char *)(theBuffer+myCurrPos), myFileSizes[ myCurrFileIndex ] ); 
+        myCurrOFile->close();  
+        delete myCurrOFile;
+        myCurrOFile = 0;
+        myCurrPos += myFileSizes[ myCurrFileIndex ];
+        myFileSizes[ myCurrFileIndex ] = 0;
+      }
+      else 
+      {
+        // old code for big files
+        size_t aSize = theBufferSize - myCurrPos;
+        myCurrOFile->write((char *)( theBuffer + myCurrPos ), aSize );
+        myFileSizes[ myCurrFileIndex ] -= aSize;
+        myCurrPos = 0;
+        break;
+      }
+    }
+  }
+}
+
+//=============================================================================
+// Function : PutNextStreamToFiles
+// Purpose  : 
+//=============================================================================
+void LightApp_Driver::PutNextStreamToFiles( ListOfFiles& theListOfFiles, 
+                                            const unsigned char* theBuffer,
+                                            const long theBufferSize, 
+                                            bool theNamesOnly )
+{
+  if ( theNamesOnly )
+    return;
+
+  std::string aDir = GetTmpDir();
+
+  //Get a temporary directory for saving a file
+  TCollection_AsciiString aTmpDir(const_cast<char*>(aDir.c_str()));
+
+  if ( !myNbFilles )
+    return;
+
+  for( ; myCurrFileIndex <= myNbFilles; myCurrFileIndex++) 
+  {
+    if ( !myCurrOFile )
+    {
+      //Put a length of the file name to myFileNameSizes
+      //int myFileNameSizes;
+      memcpy(&myFileNameSizes[ myCurrFileIndex ], (theBuffer + myCurrPos), ((sizeof(int) > 4) ? 4 : sizeof(int))); 
+      myCurrPos += 4;
+
+      char *aFileName = new char[ myFileNameSizes[ myCurrFileIndex ] ];
+      //Put a file name to aFileName
+      memcpy(aFileName, (theBuffer + myCurrPos), myFileNameSizes[ myCurrFileIndex ]); 
+      myCurrPos += myFileNameSizes[ myCurrFileIndex ];
+
+      std::string aStrFileName( aFileName );
+      theListOfFiles[ myCurrFileIndex ] = aStrFileName;
+      
+      //Put a length of the file to myFileSizes
+      if ( theNamesOnly )
+      {
+        delete[] aFileName;
+        continue;
+      }
+
+      memcpy(&myFileSizes[ myCurrFileIndex ], (theBuffer + myCurrPos), ((sizeof(long) > 8) ? 8 : sizeof(long)));
+      myCurrPos += 8;    
+
+      TCollection_AsciiString aFullPath = aTmpDir + aFileName;
+
+#ifdef WNT  
+      myCurrOFile  = new ofstream(aFullPath.ToCString(), ios::out | ios::binary);
+#else
+      myCurrOFile  = new ofstream(aFullPath.ToCString());
+#endif
+
+      delete[] aFileName;
+      
+    } //if ( !myCurrOFile )
+
+    if ( myFileSizes[ myCurrFileIndex ] <= theBufferSize - myCurrPos )
+    {
+      // old code 
+      myCurrOFile->write((char *)(theBuffer+myCurrPos), myFileSizes[ myCurrFileIndex ] ); 
+      myCurrOFile->close();  
+      delete myCurrOFile;
+      myCurrOFile = 0;
+      myCurrPos += myFileSizes[ myCurrFileIndex ];
+      myFileSizes[ myCurrFileIndex ] = 0;
+    }
+    else 
+    {
+      // old code for big files
+      size_t aFileSize = myFileSizes[ myCurrFileIndex ];
+      size_t aSize = theBufferSize - myCurrPos;
+      myCurrOFile->write((char *)( theBuffer + myCurrPos ), aSize );
+      myFileSizes[ myCurrFileIndex ] -= aSize;
+      myCurrPos = 0;
+      break;
+    }
+  } // for
+}
index e130b86dae6ed683ba999d9922981e570fe1e693..7368233fdadf001c11ce10161f950210e5c9558f 100644 (file)
@@ -25,6 +25,8 @@
 #include "vector"
 #include "map"
 
+#include <OSD_File.hxx>
+
 #ifdef WIN32
 #pragma warning( disable:4251 )
 #endif
@@ -52,10 +54,27 @@ public:
   virtual void        ClearDriverContents();
 
 protected:
+  /*
   void                PutFilesToStream(const std::string& theModuleName, unsigned char*& theBuffer,
                                        long& theBufferSize, bool theNamesOnly = false);
   ListOfFiles         PutStreamToFiles(const unsigned char* theBuffer,
                                        const long theBufferSize, bool theNamesOnly = false);
+  */
+
+  // New save
+  bool                PutFilesToFirstStream( const std::string& theModuleName, unsigned char*& theBuffer,
+                                             long& theBufferSize, bool theNamesOnly = false );
+  bool                PutFilesToNextStream( const std::string& theModuleName, unsigned char*& theBuffer,
+                                            long& theBufferSize, bool theNamesOnly = false );
+  bool                HasUnsavedData() const;
+
+  // New read
+  void                PutFirstStreamToFiles( ListOfFiles& theListOfFiles, const unsigned char* theBuffer,
+                                             const long theBufferSize, bool theNamesOnly = false);
+  void                PutNextStreamToFiles( ListOfFiles& theListOfFiles, const unsigned char* theBuffer,
+                                            const long theBufferSize, bool theNamesOnly = false);
+
+  inline static size_t GetMaxBuffSize();
 
   std::string GetTmpDir();
   std::string GetDirFromPath(const std::string& thePath);
@@ -70,6 +89,36 @@ protected:
 
 private:
   bool                                       myIsTemp;
+
+  // reading/writing
+  int                                        myCurrFileIndex;
+  
+  // writing
+  size_t                                     myCurrPos;
+  unsigned char*                             myCurrBuff;
+  ifstream*                                  myCurrIFile;
+  size_t                                     mySizeToBeWritten;
+  size_t*                                    myFileSizes;
+  size_t*                                    myFileNameSizes;
+
+  // reading
+  ofstream*                                  myCurrOFile;
+  long                                       myNbFilles;
 };
 
+inline size_t LightApp_Driver::GetMaxBuffSize()
+{
+  static size_t aValue = 0;
+  if ( !aValue )
+  {
+    char* aVar = getenv( "HDF_BUFFER_SIZE" );
+    if ( aVar )
+      aValue = (size_t)atol( aVar );
+    else
+      aValue = 50000000;
+  }
+
+  return aValue;
+}
+
 #endif 
index 20aba1ec562144a7a0308ade23ffc4377cff485c..7ddff2f200eb3764797c089bf0b79d1e4f412f76 100644 (file)
@@ -18,6 +18,7 @@
 //
 #include "LightApp_HDFDriver.h"
 
+#include "HDFexplorer.hxx"
 #include "HDFOI.hxx"
 
 // OCCT Includes
@@ -68,13 +69,6 @@ bool LightApp_HDFDriver::SaveDatasInFile( const char* theFileName, bool isMultiF
     for (it = myMap.begin(); it != myMap.end(); ++it, ++tag) {
       std::string aName (it->first);
       char* aModuleName = const_cast<char*>(aName.c_str());
-      unsigned char* aBuffer;
-      long           aBufferSize;
-      PutFilesToStream(aName, aBuffer, aBufferSize, isMultiFile);
-
-      //Handle(SALOMEDSImpl_SComponent) sco = itcomponent.Value();
-      //TCollection_AsciiString scoid = sco->GetID();
-      //hdf_sco_group = new HDFgroup(scoid.ToCString(), hdf_group_datacomponent);
 
       TCollection_AsciiString entry ("0:1:");
       entry += TCollection_AsciiString(tag);
@@ -84,14 +78,38 @@ bool LightApp_HDFDriver::SaveDatasInFile( const char* theFileName, bool isMultiF
       hdf_sco_group = new HDFgroup (entry.ToCString(), hdf_group_datacomponent);
       hdf_sco_group->CreateOnDisk();
 
-      aHDFSize[0] = aBufferSize;
+      unsigned char* aBuffer; 
+      long           aBufferSize;
+      
+      /*while( LightApp_Driver::HasUnsavedData() )
+        PutFilesToNextStream( aName, aBuffer, aBufferSize, isMultiFile );*/
 
-      hdf_dataset = new HDFdataset ("FILE_STREAM", hdf_sco_group, HDF_STRING, aHDFSize, 1);
+      // first data set
+      TCollection_AsciiString aBaseName( (Standard_CString)"FILE_STREAM" );
+      PutFilesToFirstStream( aName, aBuffer, aBufferSize, isMultiFile );
+      aHDFSize[0] = aBufferSize;
+      hdf_dataset = new HDFdataset( aBaseName.ToCString(), hdf_sco_group, HDF_STRING, aHDFSize, 1);
       hdf_dataset->CreateOnDisk();
       hdf_dataset->WriteOnDisk(aBuffer); //Save the stream in the HDF file
       hdf_dataset->CloseOnDisk();
       hdf_dataset = 0; //will be deleted by hdf_sco_group destructor
 
+     // other data sets
+      int anIndex = 0;
+      while( LightApp_Driver::HasUnsavedData() )
+      {
+        anIndex++;
+        TCollection_AsciiString aDataSetName = 
+          aBaseName + TCollection_AsciiString( anIndex );
+        PutFilesToNextStream( aName, aBuffer, aBufferSize, isMultiFile );
+        aHDFSize[0] = aBufferSize;
+        hdf_dataset = new HDFdataset( aDataSetName.ToCString(), hdf_sco_group, HDF_STRING, aHDFSize, 1);
+        hdf_dataset->CreateOnDisk();
+        hdf_dataset->WriteOnDisk(aBuffer); //Save the stream in the HDF file
+        hdf_dataset->CloseOnDisk();
+        hdf_dataset = 0; //will be deleted by hdf_sco_group destructor
+      }
+
       // store multifile state
       aHDFSize[0] = 2;
       hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1);
@@ -270,23 +288,47 @@ bool LightApp_HDFDriver::ReadDatasFromFile( const char* theFileName, bool isMult
           hdf_sco_group->OpenOnDisk();
 
           // Read component data
-          unsigned char* aStreamFile = NULL;
-          int aStreamSize = 0;
 
-          if (hdf_sco_group->ExistInternalObject("FILE_STREAM")) {
-            HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group);
-            hdf_dataset->OpenOnDisk();
-            aStreamSize = hdf_dataset->GetSize();
-            aStreamFile = new unsigned char[aStreamSize];
-            if (aStreamFile == NULL) {
-              isError = true;
-            } else {
-              hdf_dataset->ReadFromDisk(aStreamFile);
+          // read first file stream
+          TCollection_AsciiString aBaseName( (Standard_CString)"FILE_STREAM" );
+          ListOfFiles aListOfFiles;
+          for ( int ds = 0; true; ds++ ) {
+            unsigned char* aStreamFile = NULL;
+            int aStreamSize = 0;
+
+            TCollection_AsciiString aDataSetName = aBaseName;
+            if ( ds > 0  )
+              aDataSetName = aBaseName + TCollection_AsciiString( ds );
+
+            if ( hdf_sco_group->ExistInternalObject( aDataSetName.ToCString() ) ) {
+              HDFdataset *hdf_dataset = new HDFdataset( aDataSetName.ToCString(), hdf_sco_group );
+              hdf_dataset->OpenOnDisk();
+              aStreamSize = hdf_dataset->GetSize();
+              aStreamFile = new unsigned char[aStreamSize];
+              if (aStreamFile == NULL) {
+                isError = true;
+              } else {
+                hdf_dataset->ReadFromDisk(aStreamFile);
+              }
+
+              hdf_dataset->CloseOnDisk();
+              hdf_dataset = 0;
+            }
+            else 
+              break;
+
+            if ( aStreamFile != NULL ) 
+            {
+              if ( ds == 0 )
+                PutFirstStreamToFiles( aListOfFiles, aStreamFile, aStreamSize, isMultiFile );
+              else
+                PutNextStreamToFiles( aListOfFiles, aStreamFile, aStreamSize, isMultiFile );
+              delete [] aStreamFile;
             }
+          } // for ( int i = 0; true; i++ )
 
-            hdf_dataset->CloseOnDisk();
-            hdf_dataset = 0;
-          }
+          char* aCompDataType = (char*)(mapEntryName[name].c_str());
+          SetListOfFiles( aCompDataType, aListOfFiles );
 
           HDFdataset *multifile_hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group);
           multifile_hdf_dataset->OpenOnDisk();
@@ -302,15 +344,6 @@ bool LightApp_HDFDriver::ReadDatasFromFile( const char* theFileName, bool isMult
 
           isASCII = (ASCIIfileState[0] == 'A') ? true : false;
 
-          if (aStreamFile != NULL) {
-            // Put buffer to aListOfFiles and set to myMap
-            ListOfFiles aListOfFiles = PutStreamToFiles(aStreamFile, aStreamSize, isMultiFile);
-            char* aCompDataType = (char*)(mapEntryName[name].c_str());
-            SetListOfFiles(aCompDataType, aListOfFiles);
-
-            delete [] aStreamFile;
-          }
-
           hdf_sco_group->CloseOnDisk();
         }
       }
index f2e42984d53309d2563e631ae1d8cfbcb03aec19..bf91e49933c647d2ceb7629fd19ca1d32aec4902 100644 (file)
@@ -600,3 +600,13 @@ void LightApp_Module::onViewManagerAdded( SUIT_ViewManager* )
 void LightApp_Module::onViewManagerRemoved( SUIT_ViewManager* )
 {
 }
+
+/*!
+ * \brief Virtual public method called to custom update of the desktop title
+  * \param theTitle - current desktop title
+  * \return Modified desktop title
+*/
+QString LightApp_Module::updateDesktopTitle( const QString& theTitle )
+{
+  return theTitle;
+}
index 08c8eb7d3458abaca0319132830e20c7093fd105..14fd86492bd035466ee50be1a9cdca518933451e 100644 (file)
@@ -90,6 +90,9 @@ public:
   virtual LightApp_Displayer*         displayer();
   virtual LightApp_Selection*         createSelection() const;
 
+  virtual QString                     updateDesktopTitle( const QString& );
+  // Custom update desktop title
+
 public slots:
   virtual bool                        activateModule( SUIT_Study* );
   virtual bool                        deactivateModule( SUIT_Study* );
index bd4c4100d874f72e5d8e3a76ad5917c8c7a44720..61663b75108cb974c0fe5d6d2c9935eb553ca9ee 100644 (file)
@@ -34,6 +34,7 @@
 #ifndef DISABLE_SALOMEOBJECT
   #include "SALOME_Actor.h"
   #include "SALOME_ListIteratorOfListIO.hxx"
+  #include "LightApp_DataSubOwner.h"
 #endif
 
 
@@ -85,6 +86,16 @@ LightApp_SVTKDataOwner
   return myIds;
 }
 
+/*!
+  Sets dataowners ids list.
+*/
+void 
+LightApp_SVTKDataOwner
+::SetIds( const TColStd_IndexedMapOfInteger& theIds )
+{
+  myIds = theIds;
+}
+
 /*!
   Gets selection mode.
 */
@@ -191,7 +202,14 @@ LightApp_VTKSelector
            for(; anIter.More(); anIter.Next()){
              Handle(SALOME_InteractiveObject) anIO = anIter.Value();
              if(anIO->hasEntry())
-               aList.append(new LightApp_SVTKDataOwner(anIO,aViewMgr->getDesktop()));
+        {
+          LightApp_SVTKDataOwner* anOwner = 
+            new LightApp_SVTKDataOwner( anIO, aViewMgr->getDesktop() );
+          TColStd_IndexedMapOfInteger anIndex;
+          aSelector->GetIndex( anIO, anIndex );
+          anOwner->SetIds( anIndex );
+                     aList.append( anOwner );
+        }
            }
          }
        }
@@ -224,11 +242,14 @@ LightApp_VTKSelector
 
              anAppendList.Append(anIO);
              aSelector->AddOrRemoveIndex(anIO,anOwner->GetIds(),false);
-           }else if(const LightApp_DataOwner* anOwner = dynamic_cast<const LightApp_DataOwner*>(aDataOwner)){
+           }else if(const LightApp_DataSubOwner* anOwner = dynamic_cast<const LightApp_DataSubOwner*>(aDataOwner)){
              Handle(SALOME_InteractiveObject) anIO = 
-               new SALOME_InteractiveObject(anOwner->entry().toLatin1(),"");
+               new SALOME_InteractiveObject(anOwner->entry().toLatin1(),"");
              aSelector->AddIObject(anIO);
              anAppendList.Append(anIO);
+        TColStd_IndexedMapOfInteger aMap;
+        aMap.Add( anOwner->index() );
+        aSelector->AddOrRemoveIndex( anIO,aMap, false );
            }
          }
          // To remove IOs, which is not selected.
index bfdbc5d4b8b61e6935859c8014e77e207ea78998..cc500e0698ab23187212f201b3cbe74d26b1eee0 100644 (file)
@@ -59,6 +59,9 @@ class LIGHTAPP_EXPORT LightApp_SVTKDataOwner : public LightApp_DataOwner
     /*!Gets dataowners ids list.*/
     const TColStd_IndexedMapOfInteger& GetIds() const;
 
+    /*!Sets dataowners ids list.*/
+    void SetIds( const TColStd_IndexedMapOfInteger& );
+
     /*!Gets selection mode.*/
     Selection_Mode GetMode() const;
 
index e8ee43a268f51d3d82ec5b58dfd261b23b2c9106..be8e7a5de05d732d0de844a6d26f692b4e19940f 100644 (file)
@@ -514,6 +514,8 @@ void QtxWorkstackArea::removeWidget( QWidget* wid, const bool del )
   if ( !myList.contains( wid ) )
     return;
 
+  bool wasActive = wid == workstack()->activeWindow();
+
   if ( myBar->indexOf( widgetId( wid ) ) != -1 )
     myBar->removeTab( myBar->indexOf( widgetId( wid ) ) );
 
@@ -524,12 +526,19 @@ void QtxWorkstackArea::removeWidget( QWidget* wid, const bool del )
   myChild.remove( wid );
 
   if ( del )
+  {
     delete child( wid );
+    if ( myList.isEmpty() )
+      wasActive = false;
+  }
 
   if ( isNull() )
     deleteLater();
   else
     updateState();
+
+  if ( wasActive )
+    emit activated( activeWidget() );
 }
 
 /*!
@@ -1171,7 +1180,8 @@ QtxWorkstackChild::~QtxWorkstackChild()
   if ( !widget() )
     return;
 
-  disconnect( widget(), SIGNAL( destroyed( QObject* ) ), this, SLOT( onDestroyed( QObject* ) ) );
+  if( widget() )
+    disconnect( widget(), SIGNAL( destroyed( QObject* ) ), this, SLOT( onDestroyed( QObject* ) ) );
 
   widget()->hide();
   widget()->removeEventFilter( this );
index 8af1e624691eeae57c0e0dbdfbdad14d8affd106..cfe47c62bd122bd45934b4eb923ea5be1d705425 100755 (executable)
@@ -97,8 +97,6 @@ void STD_Application::start()
 */
 void STD_Application::closeApplication()
 {
-  if ( desktop() )
-    savePreferences();
   SUIT_Study* study = activeStudy();
 
   if ( study )
@@ -113,6 +111,9 @@ void STD_Application::closeApplication()
     afterCloseDoc();
   }
 
+  if ( desktop() )
+    savePreferences();
+
   setDesktop( 0 );
 
   SUIT_Application::closeApplication();
@@ -533,7 +534,7 @@ bool STD_Application::onSaveAsDoc()
     putInfo( tr( "INF_DOC_SAVING" ) + aName );
     isOk = study->saveDocumentAs( aName );
 
-    putInfo( isOk ? tr( "INF_DOC_SAVED" ).arg( aName ) : "" );
+    putInfo( isOk ? tr( "INF_DOC_SAVED" ).arg( aName ) : QString( "" ) );
 
     QApplication::restoreOverrideCursor();
 
index 1f9e4d042f6c7dac487588a3ec7b2b6c450dae20..a01f15063bf1c3b8537717ee66604f638cc6eab2 100644 (file)
@@ -295,6 +295,20 @@ void SUIT_DataBrowser::setResizeOnExpandItem( const bool on )
   myResizeOnExpandItem = on;
 }
 
+/*!
+  Ensures that object obj is visible, scrolling the list view vertically 
+  if necessary and opening (expanding) any parent items if this is required to show the item. 
+*/
+void SUIT_DataBrowser::ensureItemVisible( const SUIT_DataObject* obj )
+{
+  SUIT_ProxyModel* m = qobject_cast<SUIT_ProxyModel*>( model() );
+  if ( m ) {
+    QModelIndex index = m->index( obj );
+    if( index.isValid() )
+      treeView()->scrollTo( index );
+  }
+}
+
 /*!
   \brief Initialize object browser.
   \param root root data object
index 9ab076bb323636acae36fbc02adb58012ca25176..020927a72429a844d279f78d934b37223709cca4 100644 (file)
@@ -64,6 +64,8 @@ public:
   void             setAutoSizeColumns( const bool on );
   void             setResizeOnExpandItem( const bool on );
 
+  void             ensureItemVisible( const SUIT_DataObject* );
+
 protected:
   virtual void     contextMenuEvent( QContextMenuEvent* );
 
index 7572fba75a45bb4244dcc5394f9c1620579b6b43..1c69220d633bbb45db427f1e00e145b42875e5d9 100755 (executable)
@@ -511,6 +511,12 @@ QString SUIT_FileDlg::addExtension( const QString& fileName ) const
 
     // now we get the list of all extension masks and remove all which does not contain wildcard symbols
     QStringList extList = aPattern.split( "|", QString::SkipEmptyParts );
+
+    // This protection is added for GUITHARE application, (*.FORT21 fort21) filter. 
+    // When user selects \93fort21\94 file name then extension should not be added
+    if ( extList.contains( QFileInfo( fname ).baseName() ) )
+      return fileName;
+
     for ( int i = extList.count() - 1; i >= 0; i-- ) {
       if ( !extList[i].contains( "." ) )
         extList.removeAt( i );
index 76309c67ab834b2173a6527966d75bc98438ec4a..746d63e7754c6b7928d59cb293a0d4510aa95a0d 100755 (executable)
@@ -98,7 +98,7 @@ protected:
   virtual bool        event( QEvent* );
   QLineEdit*          lineEdit() const;
   virtual bool        acceptData();
-  QString             addExtension( const QString& ) const;
+  virtual QString     addExtension( const QString& ) const;
   bool                processPath( const QString& );
   void                addFilter( const QString& );
   static bool         hasWildCards( const QString& );
index 34ee0c10ca3ae191fa068dc2af8b5045e560de83..ed5d996b62e0e717e5335fb197d6129802a3d0d3 100755 (executable)
@@ -347,7 +347,7 @@ void SUIT_ViewManager::closeAllViews()
  */
 QString SUIT_ViewManager::getType() const
 {
-  return (!myViewModel)? "": myViewModel->getType();
+  return (!myViewModel)? QString( "" ): myViewModel->getType();
 }
 
 /*!
index 678d9de95b4b15b2fd59ad88e34a42b4fa2f50f8..9dd6777802d87381c84b14857286abd1716f9ee9 100644 (file)
@@ -59,6 +59,7 @@
 #include <vtkInteractorStyle.h>
 #include <vtkRenderWindowInteractor.h>
 #include <vtkPassThroughFilter.h>
+#include <vtkUnstructuredGrid.h>
 
 #include <TColStd_MapOfInteger.hxx>
 #include <TColStd_IndexedMapOfInteger.hxx>
@@ -122,6 +123,13 @@ namespace
 
 }
 
+bool IsThisActorPicked(SALOME_Actor *theActor, vtkActor *anAct) {
+  if( anAct == theActor ) return true;
+       if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( anAct ) )
+    return ( anActor->hasIO() && theActor->hasIO() &&
+      theActor->getIO()->isSame( anActor->getIO() ) );
+  return false;
+}
 
 vtkStandardNewMacro(SALOME_Actor);
 
@@ -448,7 +456,8 @@ SALOME_Actor
       myPointPicker->Pick( x, y, z, aRenderer );
       
       int aVtkId = myPointPicker->GetPointId();
-      if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
+      if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true )
+        && IsThisActorPicked(this, myPointPicker->GetActor())) { // RKV
        int anObjId = GetNodeObjId( aVtkId );
        myIsPreselected = (anObjId >= 0);
        if(myIsPreselected){
@@ -475,7 +484,8 @@ SALOME_Actor
       myCellPicker->Pick( x, y, z, aRenderer );
       
       int aVtkId = myCellPicker->GetCellId();
-      if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) && hasIO() ) {
+      if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) && hasIO()
+        && IsThisActorPicked(this, myCellPicker->GetActor())) { // RKV
        int anObjId = GetElemObjId (aVtkId );
        if ( anObjId >= 0 ) {
          myIsPreselected = CheckDimensionId(aSelectionMode,this,anObjId);
@@ -501,7 +511,8 @@ SALOME_Actor
       myCellPicker->Pick( x, y, z, aRenderer );
       
       int aVtkId = myCellPicker->GetCellId();
-      if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId )) {
+      if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId )
+        && IsThisActorPicked(this, myCellPicker->GetActor())) { // RKV
        int anObjId = GetElemObjId( aVtkId );
        if ( anObjId >= 0 ) {
          int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
@@ -587,7 +598,8 @@ SALOME_Actor
       myPointPicker->Pick( x, y, z, aRenderer );
 
       int aVtkId = myPointPicker->GetPointId();
-      if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
+      if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true )
+        && IsThisActorPicked(this, myPointPicker->GetActor())) { // RKV
        int anObjId = GetNodeObjId( aVtkId );
        if( anObjId >= 0 ) {
          mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
@@ -604,7 +616,8 @@ SALOME_Actor
       myCellPicker->Pick( x, y, z, aRenderer );
     
       int aVtkId = myCellPicker->GetCellId();
-      if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
+      if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId )
+        && IsThisActorPicked(this, myCellPicker->GetActor())) { // RKV
        int anObjId = GetElemObjId( aVtkId );
        if( anObjId >= 0 ) {
          if ( CheckDimensionId(aSelectionMode,this,anObjId) ) {
@@ -620,7 +633,8 @@ SALOME_Actor
       myCellPicker->Pick( x, y, z, aRenderer );
     
       int aVtkId = myCellPicker->GetCellId();
-      if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
+      if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId )
+        && IsThisActorPicked(this, myCellPicker->GetActor())) { // RKV
        int anObjId = GetElemObjId( aVtkId );
        if( anObjId >= 0 ) {
          int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
@@ -671,7 +685,8 @@ SALOME_Actor
        vtkIdType anEnd = aVectorIds.size();
        for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
          int aPointId = aVectorIds[anId];
-         if( aPointId >= 0 && mySelector->IsValid( this, aPointId, true ) ) {
+         if( aPointId >= 0 && mySelector->IsValid( this, aPointId, true )
+        && IsThisActorPicked(this, myPointRectPicker->GetActor())) { // RKV
            int anObjId = GetNodeObjId( aPointId );
            anIndexes.Add( anObjId );
          }
@@ -731,7 +746,8 @@ SALOME_Actor
        vtkIdType anEnd = aVectorIds.size();
        for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
          int aCellId = aVectorIds[anId];
-         if ( !mySelector->IsValid( this, aCellId ) )
+         if ( !mySelector->IsValid( this, aCellId )
+        && !IsThisActorPicked(this, myCellRectPicker->GetActor())) // RKV
            continue;
 
          int anObjId = GetElemObjId( aCellId );
@@ -817,3 +833,17 @@ SALOME_Actor
 {
   myHighlightActor->SetProperty(theProperty);
 }
+
+
+void
+SALOME_Actor
+::MapCells(const TColStd_IndexedMapOfInteger& theMapIndex,
+                vtkUnstructuredGrid* theUG)
+{
+  int aNbOfParts = theMapIndex.Extent();
+  for(int ind = 1; ind <= aNbOfParts; ind++){
+    int aPartId = theMapIndex( ind );
+    if(vtkCell* aCell = GetElemCell(aPartId))
+      theUG->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
+  }
+}
index 4316ef3dc59e31bc397e47e349265a2370c85373..ee81079b5a729cc25bb705d8543ecce80d4c4e19 100644 (file)
@@ -49,6 +49,7 @@ class vtkCellPicker;
 class vtkOutlineSource;
 class vtkInteractorStyle;
 class vtkRenderWindowInteractor;
+class vtkUnstructuredGrid;
 
 class SVTK_Actor;
 class SVTK_RectPicker;
@@ -202,6 +203,9 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   void
   SetHighlightProperty(vtkProperty* theProperty);
 
+  virtual void MapCells(const TColStd_IndexedMapOfInteger& theMapIndex,
+                        vtkUnstructuredGrid* theUG);
+
  protected:
   //----------------------------------------------------------------------------
   vtkRenderWindowInteractor* myInteractor;
index 8ccb82a8be5ed8a5362938a7790ce439a2bcc495..11bfa36c0e391fc722670fded5d1736b8e6fbbfd 100644 (file)
@@ -118,12 +118,7 @@ SVTK_Actor
   vtkDataSet *aSourceDataSet = theMapActor->GetInput();
   CopyPoints(GetSource(),aSourceDataSet);
 
-  int aNbOfParts = theMapIndex.Extent();
-  for(int ind = 1; ind <= aNbOfParts; ind++){
-    int aPartId = theMapIndex( ind );
-    if(vtkCell* aCell = theMapActor->GetElemCell(aPartId))
-      myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
-  }
+  theMapActor->MapCells(theMapIndex,myUnstructuredGrid.GetPointer());
 
   UnShrink();
   if(theMapActor->IsShrunk()){
index a3bb037730cf4a8d353b54196fd75b41c5ec9c0c..52dcc0a8a53b9debb1d33ee46bb6181358e80562 100644 (file)
@@ -162,7 +162,7 @@ SVTK_DeviceActor
 ::SetInput(vtkDataSet* theDataSet)
 {
   myMapper->SetInput(theDataSet);
-  InitPipeLine(myMapper);
+  SetMapper(myMapper);
 }
 
 /*!
index 6c8d3211119ffbe46f1386bcb19259712db06d15..e06d7a978b6578d269086df9c2a536b6dc85619d 100644 (file)
@@ -195,6 +195,7 @@ SVTK_InteractorStyle
 
   mySelectionEvent->myIsCtrl = Interactor->GetControlKey();
   mySelectionEvent->myIsShift = Interactor->GetShiftKey();
+  mySelectionEvent->myKeyCode = Interactor->GetKeyCode();
 
   mySelectionEvent->myLastX = mySelectionEvent->myX;
   mySelectionEvent->myLastY = mySelectionEvent->myY;
index 8d6cfe07b8b3307eddf25cd5d38580ee392529ab..79923503e3bdf606ba1665be69baa5c3027749b6 100644 (file)
@@ -91,13 +91,21 @@ namespace
 
 
   //----------------------------------------------------------------------------
+/* RKV  void
+  SelectVisiblePoints(int theSelection[4],
+                     vtkRenderer *theRenderer,
+                     vtkDataSet *theInput,
+                     SVTK_RectPicker::TVectorIds& theVisibleIds,
+                     SVTK_RectPicker::TVectorIds& theInVisibleIds,
+                     vtkFloatingPointType theTolerance) */
   void
   SelectVisiblePoints(int theSelection[4],
                      vtkRenderer *theRenderer,
                      vtkDataSet *theInput,
                      SVTK_RectPicker::TVectorIds& theVisibleIds,
                      SVTK_RectPicker::TVectorIds& theInVisibleIds,
-                     vtkFloatingPointType theTolerance)
+                     vtkFloatingPointType theTolerance, 
+          bool isThrough) // RKV
   {
     theVisibleIds.clear();
     theInVisibleIds.clear();
@@ -119,8 +127,14 @@ namespace
                       GetCompositePerspectiveTransformMatrix( theRenderer->GetTiledAspectRatio(), 0, 1 ) );
 
     // We grab the z-buffer for the selection region all at once and probe the resulting array.
-    float *aZPtr = theRenderer->GetRenderWindow()->
-      GetZbufferData(theSelection[0], theSelection[1], theSelection[2], theSelection[3]);
+// RKV    float *aZPtr = theRenderer->GetRenderWindow()->
+// RKV      GetZbufferData(theSelection[0], theSelection[1], theSelection[2], theSelection[3]);
+    // RKV : Begin
+    float *aZPtr = 0;
+    if (!isThrough) // Use Z-Buffer if only visible points should be taken
+      aZPtr = theRenderer->GetRenderWindow()->
+        GetZbufferData(theSelection[0], theSelection[1], theSelection[2], theSelection[3]);
+    // RKV : End
 
     //cout<<"theSelection = {"<<theSelection[0]<<", "<<theSelection[1]<<", "<<theSelection[2]<<", "<<theSelection[3]<<"}\n";
 
@@ -160,17 +174,24 @@ namespace
          aDX[1] >= theSelection[1] && aDX[1] <= theSelection[3])
       {
        //cout<<"aPntId "<<aPntId<<"; aDX = {"<<aDX[0]<<", "<<aDX[1]<<", "<<aDX[2]<<"}\n";
-       int aDX0 = int(aDX[0]);
-       int aDX1 = int(aDX[1]);
-
-       int aRet = Check(aZPtr,theSelection,theTolerance,aDX[2],aDX0,aDX1);
+        static int aMaxRadius = 5;
+        int aDX0 = 0;
+        int aDX1 = 0;
+        int aRet = 0;
+        int aRadius = 1;
+        
+        if (isThrough) goto ADD_VISIBLE; // RKV
+
+       aDX0 = int(aDX[0]);
+       aDX1 = int(aDX[1]);
+
+       aRet = Check(aZPtr,theSelection,theTolerance,aDX[2],aDX0,aDX1);
        if(aRet > 0)
          goto ADD_VISIBLE;
        if(aRet < 0)
          goto ADD_INVISIBLE;
 
-       static int aMaxRadius = 5;
-       for(int aRadius = 1; aRadius < aMaxRadius; aRadius++){
+       for(aRadius = 1; aRadius < aMaxRadius; aRadius++){
          int aStartDX[2] = {aDX0 - aRadius, aDX1 - aRadius};
          for(int i = 0; i <= aRadius; i++){
            int aRet = Check(aZPtr,theSelection,theTolerance,aDX[2],aStartDX[0]++,aStartDX[1]);
@@ -231,7 +252,8 @@ namespace
                     vtkRenderer *theRenderer,
                     vtkDataSet *theInput,
                     SVTK_RectPicker::TVectorIds& theVectorIds,
-                    vtkFloatingPointType theTolerance)
+// RKV              vtkFloatingPointType theTolerance)
+                    vtkFloatingPointType theTolerance, bool isThrough) // RKV
   {
     theVectorIds.clear();
 
@@ -248,7 +270,8 @@ namespace
                        theInput,
                        aVisiblePntIds,
                        anInVisiblePntIds,
-                       theTolerance);
+// RKV                 theTolerance);
+                       theTolerance, isThrough); // RKV
 
     typedef std::set<vtkIdType> TIdsSet;
     TIdsSet aVisibleIds(aVisiblePntIds.begin(),aVisiblePntIds.end());
@@ -337,6 +360,7 @@ SVTK_RectPicker
 {
   this->Tolerance = 0.005;
   this->PickPoints = 1;
+  this->myIsThrough = false; // RKV : The old behaviour by default
 }
 
 SVTK_RectPicker
@@ -457,7 +481,8 @@ SVTK_RectPicker
                              aMapper->GetInput(),
                              aVisibleIds,
                              anInVisibleIds,
-                             this->Tolerance);
+// RKV                       this->Tolerance);
+                             this->Tolerance, IsThrough()); // RKV
          if ( aVisibleIds.empty() ) {
            myPointIdsMap.erase(myPointIdsMap.find(anActor));
          }
@@ -467,7 +492,8 @@ SVTK_RectPicker
                             theRenderer,
                             aMapper->GetInput(),
                             aVectorIds,
-                            this->Tolerance);
+// RKV                      this->Tolerance);
+                            this->Tolerance, IsThrough()); // RKV
          if ( aVectorIds.empty() ) {
            myCellIdsMap.erase(myCellIdsMap.find(anActor));
          }
index 3a6576edb04ec5eef0dbfbb9d3ffb230fc941978..59e152eabc43c7f247bfbd02328b8d9042da28ce 100644 (file)
@@ -93,6 +93,9 @@ class SVTK_EXPORT SVTK_RectPicker : public vtkAbstractPropPicker
   const TVectorIdsMap& 
   GetCellIdsMap() const;
 
+  bool IsThrough() { return myIsThrough;} // RKV
+  void SetIsThrough(bool val) { myIsThrough = val;} // RKV
+
  protected:
   SVTK_RectPicker();
   ~SVTK_RectPicker();
@@ -112,6 +115,9 @@ class SVTK_EXPORT SVTK_RectPicker : public vtkAbstractPropPicker
   TVectorIdsMap myPointIdsMap;
   TVectorIdsMap myCellIdsMap;
 
+  bool myIsThrough; // RKV : Will the picker take all elements throuth selected 
+                    // volume inclung invizible elements
+
  private:
   virtual 
   int
index 66287bf793afe5f5fed35bef99bf9a5b2d8415c3..6f96493b570a4ae088263fc9e29ff48f3b8923ee 100644 (file)
@@ -245,10 +245,15 @@ void
 QVTK_RenderWindowInteractor
 ::mouseMoveEvent( QMouseEvent* event ) 
 {
+  int keyCode = 0;
+  if ( event->modifiers() & Qt::AltModifier )
+    keyCode = Qt::Key_Alt;
+
   GetDevice()->SetEventInformationFlipY(event->x(), 
                                        event->y(),
                                        event->modifiers() & Qt::ControlModifier,
-                                       event->modifiers() & Qt::ShiftModifier);
+                                       event->modifiers() & Qt::ShiftModifier,
+          keyCode);
   GetDevice()->MouseMoveEvent();
 }
 
@@ -260,10 +265,15 @@ void
 QVTK_RenderWindowInteractor
 ::mousePressEvent( QMouseEvent* event ) 
 {
+  int keyCode = 0;
+  if ( event->modifiers() & Qt::AltModifier )
+    keyCode = Qt::Key_Alt;
+
   GetDevice()->SetEventInformationFlipY(event->x(), 
                                        event->y(),
                                        event->modifiers() & Qt::ControlModifier,
-                                       event->modifiers() & Qt::ShiftModifier);
+                                       event->modifiers() & Qt::ShiftModifier,
+          keyCode);
   if( event->button() & Qt::LeftButton )
     GetDevice()->LeftButtonPressEvent();
   else if( event->button() & Qt::MidButton )
@@ -280,10 +290,15 @@ void
 QVTK_RenderWindowInteractor
 ::mouseReleaseEvent( QMouseEvent *event )
 {
+  int keyCode = 0;
+  if ( event->modifiers() & Qt::AltModifier )
+    keyCode = Qt::Key_Alt;
+
   GetDevice()->SetEventInformationFlipY(event->x(), 
                                        event->y(),
                                        event->modifiers() & Qt::ControlModifier,
-                                       event->modifiers() & Qt::ShiftModifier);
+                                       event->modifiers() & Qt::ShiftModifier,
+          keyCode);
 
   if( event->button() & Qt::LeftButton )
     GetDevice()->LeftButtonReleaseEvent();
index b8edb171c6a705b1030d7668bc7481c2f98b2441..ddea0b98ad5cc340121283674749edc0f76d568f 100644 (file)
@@ -399,7 +399,8 @@ SVTK_Viewer
            //if(!anObj.IsNull() && anObj->hasEntry() && aStudy)
            //  ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this);
            if(forced)
-             aRenderer->RemoveActor(anAct);
+             // RKV : aRenderer->RemoveActor(anAct);
+        anAct->RemoveFromRender(aRenderer); // RKV
            else{
              // just erase actor
              anAct->SetVisibility( false );