From d8e3aa22fef8fa70d3ce18770bc5079845b5cfda Mon Sep 17 00:00:00 2001 From: ouv Date: Mon, 8 Sep 2008 13:22:37 +0000 Subject: [PATCH] Merging from branch For_CTH_V12 --- src/DDS/DDS_DicGroup.cxx | 2 + src/DDS/DDS_DicItem.cxx | 2 + src/LightApp/LightApp_Application.cxx | 11 +- src/LightApp/LightApp_Dialog.cxx | 2 +- src/LightApp/LightApp_Driver.cxx | 651 +++++++++++++++++------ src/LightApp/LightApp_Driver.h | 49 ++ src/LightApp/LightApp_HDFDriver.cxx | 97 ++-- src/LightApp/LightApp_Module.cxx | 10 + src/LightApp/LightApp_Module.h | 3 + src/LightApp/LightApp_VTKSelector.cxx | 27 +- src/LightApp/LightApp_VTKSelector.h | 3 + src/Qtx/QtxWorkstack.cxx | 12 +- src/STD/STD_Application.cxx | 7 +- src/SUIT/SUIT_DataBrowser.cxx | 14 + src/SUIT/SUIT_DataBrowser.h | 2 + src/SUIT/SUIT_FileDlg.cxx | 6 + src/SUIT/SUIT_FileDlg.h | 2 +- src/SUIT/SUIT_ViewManager.cxx | 2 +- src/SVTK/SALOME_Actor.cxx | 46 +- src/SVTK/SALOME_Actor.h | 4 + src/SVTK/SVTK_Actor.cxx | 7 +- src/SVTK/SVTK_DeviceActor.cxx | 2 +- src/SVTK/SVTK_InteractorStyle.cxx | 1 + src/SVTK/SVTK_RectPicker.cxx | 52 +- src/SVTK/SVTK_RectPicker.h | 6 + src/SVTK/SVTK_RenderWindowInteractor.cxx | 21 +- src/SVTK/SVTK_ViewModel.cxx | 3 +- 27 files changed, 791 insertions(+), 253 deletions(-) diff --git a/src/DDS/DDS_DicGroup.cxx b/src/DDS/DDS_DicGroup.cxx index 3bb337ad3..a93416dfc 100644 --- a/src/DDS/DDS_DicGroup.cxx +++ b/src/DDS/DDS_DicGroup.cxx @@ -30,6 +30,8 @@ #include #include +#include + IMPLEMENT_STANDARD_HANDLE(DDS_DicGroup, MMgt_TShared) IMPLEMENT_STANDARD_RTTIEXT(DDS_DicGroup, MMgt_TShared) diff --git a/src/DDS/DDS_DicItem.cxx b/src/DDS/DDS_DicItem.cxx index 12a942705..86e062bf4 100644 --- a/src/DDS/DDS_DicItem.cxx +++ b/src/DDS/DDS_DicItem.cxx @@ -32,6 +32,8 @@ #include #include +#include + IMPLEMENT_STANDARD_HANDLE(DDS_DicItem, MMgt_TShared) IMPLEMENT_STANDARD_RTTIEXT(DDS_DicItem, MMgt_TShared) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index fd22e1e9b..47bbb1290 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -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(); diff --git a/src/LightApp/LightApp_Dialog.cxx b/src/LightApp/LightApp_Dialog.cxx index 049dc244c..8ad4dff9b 100644 --- a/src/LightApp/LightApp_Dialog.cxx +++ b/src/LightApp/LightApp_Dialog.cxx @@ -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( "" ); } /*! diff --git a/src/LightApp/LightApp_Driver.cxx b/src/LightApp/LightApp_Driver.cxx index 08c1d2cdf..08b791f66 100644 --- a/src/LightApp/LightApp_Driver.cxx +++ b/src/LightApp/LightApp_Driver.cxx @@ -35,13 +35,24 @@ /*! 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 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(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(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(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(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 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(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 is a directory with slash at the end. Other items are names of files. If 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(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(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(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(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(aFiles[0].c_str())); + + size_t aCurrSize = mySizeToBeWritten <= GetMaxBuffSize() ? mySizeToBeWritten : GetMaxBuffSize(); + + for ( ; myCurrFileIndex < aLength; myCurrFileIndex++ ) + { + TCollection_AsciiString aName(const_cast(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(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(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(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 +} diff --git a/src/LightApp/LightApp_Driver.h b/src/LightApp/LightApp_Driver.h index e130b86da..7368233fd 100644 --- a/src/LightApp/LightApp_Driver.h +++ b/src/LightApp/LightApp_Driver.h @@ -25,6 +25,8 @@ #include "vector" #include "map" +#include + #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 diff --git a/src/LightApp/LightApp_HDFDriver.cxx b/src/LightApp/LightApp_HDFDriver.cxx index 20aba1ec5..7ddff2f20 100644 --- a/src/LightApp/LightApp_HDFDriver.cxx +++ b/src/LightApp/LightApp_HDFDriver.cxx @@ -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(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(); } } diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index f2e42984d..bf91e4993 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -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; +} diff --git a/src/LightApp/LightApp_Module.h b/src/LightApp/LightApp_Module.h index 08c8eb7d3..14fd86492 100644 --- a/src/LightApp/LightApp_Module.h +++ b/src/LightApp/LightApp_Module.h @@ -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* ); diff --git a/src/LightApp/LightApp_VTKSelector.cxx b/src/LightApp/LightApp_VTKSelector.cxx index bd4c4100d..61663b751 100644 --- a/src/LightApp/LightApp_VTKSelector.cxx +++ b/src/LightApp/LightApp_VTKSelector.cxx @@ -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(aDataOwner)){ + }else if(const LightApp_DataSubOwner* anOwner = dynamic_cast(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. diff --git a/src/LightApp/LightApp_VTKSelector.h b/src/LightApp/LightApp_VTKSelector.h index bfdbc5d4b..cc500e069 100644 --- a/src/LightApp/LightApp_VTKSelector.h +++ b/src/LightApp/LightApp_VTKSelector.h @@ -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; diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index e8ee43a26..be8e7a5de 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -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 ); diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index 8af1e6246..cfe47c62b 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -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(); diff --git a/src/SUIT/SUIT_DataBrowser.cxx b/src/SUIT/SUIT_DataBrowser.cxx index 1f9e4d042..a01f15063 100644 --- a/src/SUIT/SUIT_DataBrowser.cxx +++ b/src/SUIT/SUIT_DataBrowser.cxx @@ -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( model() ); + if ( m ) { + QModelIndex index = m->index( obj ); + if( index.isValid() ) + treeView()->scrollTo( index ); + } +} + /*! \brief Initialize object browser. \param root root data object diff --git a/src/SUIT/SUIT_DataBrowser.h b/src/SUIT/SUIT_DataBrowser.h index 9ab076bb3..020927a72 100644 --- a/src/SUIT/SUIT_DataBrowser.h +++ b/src/SUIT/SUIT_DataBrowser.h @@ -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* ); diff --git a/src/SUIT/SUIT_FileDlg.cxx b/src/SUIT/SUIT_FileDlg.cxx index 7572fba75..1c69220d6 100755 --- a/src/SUIT/SUIT_FileDlg.cxx +++ b/src/SUIT/SUIT_FileDlg.cxx @@ -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 “fort21” 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 ); diff --git a/src/SUIT/SUIT_FileDlg.h b/src/SUIT/SUIT_FileDlg.h index 76309c67a..746d63e77 100755 --- a/src/SUIT/SUIT_FileDlg.h +++ b/src/SUIT/SUIT_FileDlg.h @@ -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& ); diff --git a/src/SUIT/SUIT_ViewManager.cxx b/src/SUIT/SUIT_ViewManager.cxx index 34ee0c10c..ed5d996b6 100755 --- a/src/SUIT/SUIT_ViewManager.cxx +++ b/src/SUIT/SUIT_ViewManager.cxx @@ -347,7 +347,7 @@ void SUIT_ViewManager::closeAllViews() */ QString SUIT_ViewManager::getType() const { - return (!myViewModel)? "": myViewModel->getType(); + return (!myViewModel)? QString( "" ): myViewModel->getType(); } /*! diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index 678d9de95..9dd677780 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -59,6 +59,7 @@ #include #include #include +#include #include #include @@ -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()); + } +} diff --git a/src/SVTK/SALOME_Actor.h b/src/SVTK/SALOME_Actor.h index 4316ef3dc..ee81079b5 100644 --- a/src/SVTK/SALOME_Actor.h +++ b/src/SVTK/SALOME_Actor.h @@ -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; diff --git a/src/SVTK/SVTK_Actor.cxx b/src/SVTK/SVTK_Actor.cxx index 8ccb82a8b..11bfa36c0 100644 --- a/src/SVTK/SVTK_Actor.cxx +++ b/src/SVTK/SVTK_Actor.cxx @@ -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()){ diff --git a/src/SVTK/SVTK_DeviceActor.cxx b/src/SVTK/SVTK_DeviceActor.cxx index a3bb03773..52dcc0a8a 100644 --- a/src/SVTK/SVTK_DeviceActor.cxx +++ b/src/SVTK/SVTK_DeviceActor.cxx @@ -162,7 +162,7 @@ SVTK_DeviceActor ::SetInput(vtkDataSet* theDataSet) { myMapper->SetInput(theDataSet); - InitPipeLine(myMapper); + SetMapper(myMapper); } /*! diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index 6c8d32111..e06d7a978 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -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; diff --git a/src/SVTK/SVTK_RectPicker.cxx b/src/SVTK/SVTK_RectPicker.cxx index 8d6cfe07b..79923503e 100644 --- a/src/SVTK/SVTK_RectPicker.cxx +++ b/src/SVTK/SVTK_RectPicker.cxx @@ -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[1] && aDX[1] <= theSelection[3]) { //cout<<"aPntId "< 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 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)); } diff --git a/src/SVTK/SVTK_RectPicker.h b/src/SVTK/SVTK_RectPicker.h index 3a6576edb..59e152eab 100644 --- a/src/SVTK/SVTK_RectPicker.h +++ b/src/SVTK/SVTK_RectPicker.h @@ -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 diff --git a/src/SVTK/SVTK_RenderWindowInteractor.cxx b/src/SVTK/SVTK_RenderWindowInteractor.cxx index 66287bf79..6f96493b5 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.cxx +++ b/src/SVTK/SVTK_RenderWindowInteractor.cxx @@ -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(); diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index b8edb171c..ddea0b98a 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -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 ); -- 2.39.2