#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)
#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)
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.*/
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 );
}
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();
*/
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( "" );
}
/*!
/*! 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;
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++;
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;
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,
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
+}
#include "vector"
#include "map"
+#include <OSD_File.hxx>
+
#ifdef WIN32
#pragma warning( disable:4251 )
#endif
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);
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
//
#include "LightApp_HDFDriver.h"
+#include "HDFexplorer.hxx"
#include "HDFOI.hxx"
// OCCT Includes
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);
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);
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();
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();
}
}
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;
+}
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* );
#ifndef DISABLE_SALOMEOBJECT
#include "SALOME_Actor.h"
#include "SALOME_ListIteratorOfListIO.hxx"
+ #include "LightApp_DataSubOwner.h"
#endif
return myIds;
}
+/*!
+ Sets dataowners ids list.
+*/
+void
+LightApp_SVTKDataOwner
+::SetIds( const TColStd_IndexedMapOfInteger& theIds )
+{
+ myIds = theIds;
+}
+
/*!
Gets selection mode.
*/
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 );
+ }
}
}
}
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.
/*!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;
if ( !myList.contains( wid ) )
return;
+ bool wasActive = wid == workstack()->activeWindow();
+
if ( myBar->indexOf( widgetId( wid ) ) != -1 )
myBar->removeTab( myBar->indexOf( widgetId( wid ) ) );
myChild.remove( wid );
if ( del )
+ {
delete child( wid );
+ if ( myList.isEmpty() )
+ wasActive = false;
+ }
if ( isNull() )
deleteLater();
else
updateState();
+
+ if ( wasActive )
+ emit activated( activeWidget() );
}
/*!
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 );
*/
void STD_Application::closeApplication()
{
- if ( desktop() )
- savePreferences();
SUIT_Study* study = activeStudy();
if ( study )
afterCloseDoc();
}
+ if ( desktop() )
+ savePreferences();
+
setDesktop( 0 );
SUIT_Application::closeApplication();
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();
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
void setAutoSizeColumns( const bool on );
void setResizeOnExpandItem( const bool on );
+ void ensureItemVisible( const SUIT_DataObject* );
+
protected:
virtual void contextMenuEvent( QContextMenuEvent* );
// 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 );
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& );
*/
QString SUIT_ViewManager::getType() const
{
- return (!myViewModel)? "": myViewModel->getType();
+ return (!myViewModel)? QString( "" ): myViewModel->getType();
}
/*!
#include <vtkInteractorStyle.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPassThroughFilter.h>
+#include <vtkUnstructuredGrid.h>
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
}
+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);
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){
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);
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);
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 );
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) ) {
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);
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 );
}
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 );
{
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());
+ }
+}
class vtkOutlineSource;
class vtkInteractorStyle;
class vtkRenderWindowInteractor;
+class vtkUnstructuredGrid;
class SVTK_Actor;
class SVTK_RectPicker;
void
SetHighlightProperty(vtkProperty* theProperty);
+ virtual void MapCells(const TColStd_IndexedMapOfInteger& theMapIndex,
+ vtkUnstructuredGrid* theUG);
+
protected:
//----------------------------------------------------------------------------
vtkRenderWindowInteractor* myInteractor;
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()){
::SetInput(vtkDataSet* theDataSet)
{
myMapper->SetInput(theDataSet);
- InitPipeLine(myMapper);
+ SetMapper(myMapper);
}
/*!
mySelectionEvent->myIsCtrl = Interactor->GetControlKey();
mySelectionEvent->myIsShift = Interactor->GetShiftKey();
+ mySelectionEvent->myKeyCode = Interactor->GetKeyCode();
mySelectionEvent->myLastX = mySelectionEvent->myX;
mySelectionEvent->myLastY = mySelectionEvent->myY;
//----------------------------------------------------------------------------
+/* 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();
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";
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]);
vtkRenderer *theRenderer,
vtkDataSet *theInput,
SVTK_RectPicker::TVectorIds& theVectorIds,
- vtkFloatingPointType theTolerance)
+// RKV vtkFloatingPointType theTolerance)
+ vtkFloatingPointType theTolerance, bool isThrough) // RKV
{
theVectorIds.clear();
theInput,
aVisiblePntIds,
anInVisiblePntIds,
- theTolerance);
+// RKV theTolerance);
+ theTolerance, isThrough); // RKV
typedef std::set<vtkIdType> TIdsSet;
TIdsSet aVisibleIds(aVisiblePntIds.begin(),aVisiblePntIds.end());
{
this->Tolerance = 0.005;
this->PickPoints = 1;
+ this->myIsThrough = false; // RKV : The old behaviour by default
}
SVTK_RectPicker
aMapper->GetInput(),
aVisibleIds,
anInVisibleIds,
- this->Tolerance);
+// RKV this->Tolerance);
+ this->Tolerance, IsThrough()); // RKV
if ( aVisibleIds.empty() ) {
myPointIdsMap.erase(myPointIdsMap.find(anActor));
}
theRenderer,
aMapper->GetInput(),
aVectorIds,
- this->Tolerance);
+// RKV this->Tolerance);
+ this->Tolerance, IsThrough()); // RKV
if ( aVectorIds.empty() ) {
myCellIdsMap.erase(myCellIdsMap.find(anActor));
}
const TVectorIdsMap&
GetCellIdsMap() const;
+ bool IsThrough() { return myIsThrough;} // RKV
+ void SetIsThrough(bool val) { myIsThrough = val;} // RKV
+
protected:
SVTK_RectPicker();
~SVTK_RectPicker();
TVectorIdsMap myPointIdsMap;
TVectorIdsMap myCellIdsMap;
+ bool myIsThrough; // RKV : Will the picker take all elements throuth selected
+ // volume inclung invizible elements
+
private:
virtual
int
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();
}
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 )
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();
//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 );