From: rnv Date: Wed, 29 Aug 2018 11:23:41 +0000 (+0300) Subject: SALOME 9.1.0 Windows version X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ef642d56f9f3818be97b6fbba6d19a4c1a7d1313;p=modules%2Fgui.git SALOME 9.1.0 Windows version --- diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index 7721f9f62..00da56461 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -320,13 +320,25 @@ CAM_Module* CAM_Application::loadModule( const QString& modName, const bool show GET_VERSION_FUNC getVersion = 0; #ifdef WIN32 - HINSTANCE modLib = ::LoadLibrary( libName.toUtf8() ); + +#ifdef UNICODE + LPTSTR str_libname = new TCHAR[libName.length() + 1]; + str_libname[libName.toWCharArray(str_libname)] = '\0'; +#else + LPTSTR str_libname = libName.toLatin1().constData(); +#endif + HINSTANCE modLib = ::LoadLibrary( str_libname ); if ( !modLib ) { LPVOID lpMsgBuf; ::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, ::GetLastError(), 0, (LPTSTR)&lpMsgBuf, 0, 0 ); - err = QString( "Failed to load %1. %2" ).arg( libName ).arg( (LPTSTR)lpMsgBuf ); +#ifdef UNICODE + QString out_err = QString::fromWCharArray((LPTSTR)lpMsgBuf); +#else + QString out_err = (LPTSTR)lpMsgBuf; +#endif + err = QString( "Failed to load %1. %2" ).arg( libName ).arg(out_err); ::LocalFree( lpMsgBuf ); } else @@ -337,8 +349,14 @@ CAM_Module* CAM_Application::loadModule( const QString& modName, const bool show LPVOID lpMsgBuf; ::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, ::GetLastError(), 0, (LPTSTR)&lpMsgBuf, 0, 0 ); - err = QString( "Failed to find %1 function. %2" ).arg( GET_MODULE_NAME ).arg( (LPTSTR)lpMsgBuf ); - ::LocalFree( lpMsgBuf ); +#ifdef UNICODE + QString out_err = QString::fromWCharArray((LPTSTR)lpMsgBuf); +#else + QString out_err = (LPTSTR)lpMsgBuf; +#endif + + err = QString( "Failed to find %1 function. %2" ).arg( GET_MODULE_NAME ).arg( out_err ); + ::LocalFree( lpMsgBuf ); } getVersion = (GET_VERSION_FUNC)::GetProcAddress( modLib, GET_VERSION_NAME ); diff --git a/src/CAM/CAM_Module.cxx b/src/CAM/CAM_Module.cxx index a5bcaf714..fd814543e 100755 --- a/src/CAM/CAM_Module.cxx +++ b/src/CAM/CAM_Module.cxx @@ -338,8 +338,10 @@ void CAM_Module::putInfo( const QString& msg, const int msec ) */ int CAM_Module::showNotification( const QString& message, const QString& title, int timeout ) { + int res = -1; if ( application() ) - application()->showNotification( message, title, timeout ); + res = application()->showNotification( message, title, timeout ); + return res; } /*! diff --git a/src/CASCatch/CASCatch_CatchSignals.cxx b/src/CASCatch/CASCatch_CatchSignals.cxx index 9ece89eef..5cb436f7f 100644 --- a/src/CASCatch/CASCatch_CatchSignals.cxx +++ b/src/CASCatch/CASCatch_CatchSignals.cxx @@ -201,7 +201,7 @@ void CASCatch_CatchSignals::Deactivate() #else //====================================== WIN32 part ==================================================== -#include +#include #include #include diff --git a/src/GLViewer/GLViewer_BaseObjects.cxx b/src/GLViewer/GLViewer_BaseObjects.cxx index cf12ae7ba..6e65422f2 100644 --- a/src/GLViewer/GLViewer_BaseObjects.cxx +++ b/src/GLViewer/GLViewer_BaseObjects.cxx @@ -1465,8 +1465,13 @@ bool GLViewer_TextObject::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerC HGDIOBJ old1 = SelectObject( dc, aFont ); HGDIOBJ old2 = SelectObject( dc, aBrush ); - - TextOut( dc, x, y, aText.toLatin1().constData(), aText.length() ); +#ifdef UNICODE + LPTSTR str = new TCHAR[aText.length() + 1]; + str[aText.toWCharArray(str)] = '\0'; +#else + LPTSTR str = aText.toLatin1().constData(); +#endif + TextOut( dc, x, y, str, aText.length() ); SelectObject ( dc, old1 ); SelectObject ( dc, old2 ); diff --git a/src/GLViewer/GLViewer_Viewer2d.cxx b/src/GLViewer/GLViewer_Viewer2d.cxx index e79b9f3a5..b11c4d710 100644 --- a/src/GLViewer/GLViewer_Viewer2d.cxx +++ b/src/GLViewer/GLViewer_Viewer2d.cxx @@ -793,7 +793,16 @@ bool GLViewer_Viewer2d::translateTo( VectorFileType aType, QString FileName, Pap HDC screen_dc = GetDC( 0 ); //The screen device context HDC bitDC = CreateCompatibleDC ( screen_dc ); //The context compatible with screen - hMetaFileDC = CreateEnhMetaFile( bitDC, FileName.toUtf8().data(), &r, "" ); +#ifdef UNICODE + LPTSTR str = new TCHAR[FileName.length() + 1]; + str[FileName.toWCharArray(str)] = '\0'; + LPTSTR empty = L""; +#else + LPTSTR str = FileName.toLatin1().constData(); + LPTSTR empty = ""; +#endif + + hMetaFileDC = CreateEnhMetaFile( bitDC, str, &r, empty ); SetMapMode( hMetaFileDC, MM_HIMETRIC ); SetWindowOrgEx( hMetaFileDC, 0, r.bottom, NULL ); HRGN ClipRgn = CreateRectRgn( 0, 0, AW, AH ); diff --git a/src/LightApp/LightApp_OCCSelector.h b/src/LightApp/LightApp_OCCSelector.h index 06026d2ad..d11d3978c 100644 --- a/src/LightApp/LightApp_OCCSelector.h +++ b/src/LightApp/LightApp_OCCSelector.h @@ -67,7 +67,7 @@ protected: virtual void setSelection( const SUIT_DataOwnerPtrList& ); #ifndef DISABLE_OCCVIEWER - virtual QString entry( const Handle_AIS_InteractiveObject& ) const; + virtual QString entry( const Handle(AIS_InteractiveObject)& ) const; #endif SUIT_DataOwnerPtrList mySelectedExternals; diff --git a/src/LightApp/LightApp_SelectionMgr.h b/src/LightApp/LightApp_SelectionMgr.h index 1bf69dc32..ec10c2a3f 100644 --- a/src/LightApp/LightApp_SelectionMgr.h +++ b/src/LightApp/LightApp_SelectionMgr.h @@ -100,7 +100,7 @@ private: virtual void selectionChanged( SUIT_Selector* ); #ifndef DISABLE_SALOMEOBJECT - QList selectionCache( const QString& = QString() ) const; + QList selectionCache( const QString& = QString() ) const; #else QStringList selectionCache( const QString& = QString() ) const; #endif @@ -110,7 +110,7 @@ private: private: #ifndef DISABLE_SALOMEOBJECT - typedef Handle_SALOME_InteractiveObject SelObject; + typedef Handle(SALOME_InteractiveObject) SelObject; #else typedef QString SelObject; #endif diff --git a/src/OCCViewer/OCCViewer_ClippingDlg.cxx b/src/OCCViewer/OCCViewer_ClippingDlg.cxx index 59ea3461e..3d33406df 100644 --- a/src/OCCViewer/OCCViewer_ClippingDlg.cxx +++ b/src/OCCViewer/OCCViewer_ClippingDlg.cxx @@ -1441,7 +1441,7 @@ void OCCViewer_ClippingDlg::onApply() /*! SLOT: Called when clip plane is clicked in viewer. */ -void OCCViewer_ClippingDlg::onPlaneClicked( const Handle(AIS_Plane)& thePlane ) +void OCCViewer_ClippingDlg::onPlaneClicked( const Handle_AIS_Plane& thePlane ) { for ( int aPlaneIt = 0; aPlaneIt < myPreviewPlaneVector.size(); aPlaneIt++ ) { @@ -1460,7 +1460,7 @@ void OCCViewer_ClippingDlg::onPlaneClicked( const Handle(AIS_Plane)& thePlane ) /*! SLOT: Called when clip plane is changed by dragging in viewer. */ -void OCCViewer_ClippingDlg::onPlaneDragged( const Handle(AIS_Plane)& thePlane ) +void OCCViewer_ClippingDlg::onPlaneDragged( const Handle_AIS_Plane& thePlane ) { for ( int aPlaneIt = 0; aPlaneIt < myPreviewPlaneVector.size(); aPlaneIt++ ) { diff --git a/src/OpenGLUtils/OpenGLUtils_FrameBuffer.cxx b/src/OpenGLUtils/OpenGLUtils_FrameBuffer.cxx index 891ae6511..700cafea8 100755 --- a/src/OpenGLUtils/OpenGLUtils_FrameBuffer.cxx +++ b/src/OpenGLUtils/OpenGLUtils_FrameBuffer.cxx @@ -24,6 +24,7 @@ #define GL_GLEXT_PROTOTYPES #endif + #include "OpenGLUtils_FrameBuffer.h" #include @@ -152,7 +153,7 @@ OpenGLUtils_FrameBuffer::~OpenGLUtils_FrameBuffer() bool OpenGLUtils_FrameBuffer::init( const GLsizei& xSize, const GLsizei& ySize ) { -#ifdef VTK_OPENGL2 +#if defined(VTK_OPENGL2) && ! defined(WIN32) int n = 0; std::ostringstream strm; glGetIntegerv(GL_NUM_EXTENSIONS, &n); diff --git a/src/PVServerService/ServiceLoader/CMakeLists.txt b/src/PVServerService/ServiceLoader/CMakeLists.txt index 7e5c65ece..d0b94d01d 100644 --- a/src/PVServerService/ServiceLoader/CMakeLists.txt +++ b/src/PVServerService/ServiceLoader/CMakeLists.txt @@ -59,7 +59,13 @@ INSTALL(TARGETS PVServerServiceLoader EXPORT ${PROJECT_NAME}TargetGroup DESTINAT # --- SWIG part --- SET_SOURCE_FILES_PROPERTIES(${_SWIG} PROPERTIES CPLUSPLUS ON) SET_SOURCE_FILES_PROPERTIES(${_SWIG} PROPERTIES SWIG_FLAGS "-py3") -SWIG_ADD_MODULE(PVServer_ServiceLoader python ${_SWIG}) +IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") + SWIG_ADD_MODULE(PVServer_ServiceLoader python ${_SWIG}) +ELSE() + SWIG_ADD_LIBRARY(PVServer_ServiceLoader LANGUAGE python SOURCES ${_SWIG}) +ENDIF() + + IF(WIN32) SET_TARGET_PROPERTIES(_PVServer_ServiceLoader PROPERTIES DEBUG_OUTPUT_NAME _PVServer_ServiceLoader_d) ENDIF(WIN32) diff --git a/src/Qtx/Qtx.cxx b/src/Qtx/Qtx.cxx index 672fa3f8e..e976086b1 100755 --- a/src/Qtx/Qtx.cxx +++ b/src/Qtx/Qtx.cxx @@ -2225,7 +2225,11 @@ void Qtx::initDefaultSurfaceFormat() fmt.setBlueBufferSize(1); fmt.setDepthBufferSize(1); fmt.setStencilBufferSize(0); +#ifdef WIN32 + fmt.setAlphaBufferSize(0); +#else fmt.setAlphaBufferSize(1); +#endif fmt.setStereo(false); fmt.setSamples(0); diff --git a/src/Qtx/QtxNotify.h b/src/Qtx/QtxNotify.h index f5647c7c2..20d3b2c4c 100644 --- a/src/Qtx/QtxNotify.h +++ b/src/Qtx/QtxNotify.h @@ -23,6 +23,8 @@ #ifndef QTXNOTIFY_H #define QTXNOTIFY_H +#include "Qtx.h" + #include #include @@ -30,7 +32,7 @@ class QTimer; -class QtxNotify : public QObject +class QTX_EXPORT QtxNotify : public QObject { Q_OBJECT diff --git a/src/SALOME_SWIG/CMakeLists.txt b/src/SALOME_SWIG/CMakeLists.txt index 79a410f61..34215e839 100755 --- a/src/SALOME_SWIG/CMakeLists.txt +++ b/src/SALOME_SWIG/CMakeLists.txt @@ -82,7 +82,13 @@ SET(_other_SCRIPTS # --- rules --- -SWIG_ADD_MODULE(libSALOME_Swig python libSALOME_Swig.i SALOMEGUI_Swig.cxx) + +IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") + SWIG_ADD_MODULE(libSALOME_Swig python libSALOME_Swig.i SALOMEGUI_Swig.cxx) +ELSE() + SWIG_ADD_LIBRARY(libSALOME_Swig LANGUAGE python SOURCES libSALOME_Swig.i SALOMEGUI_Swig.cxx) +ENDIF() + SWIG_LINK_LIBRARIES(libSALOME_Swig ${PYTHON_LIBRARIES} LightApp) IF(WIN32) SET_TARGET_PROPERTIES(_libSALOME_Swig PROPERTIES DEBUG_OUTPUT_NAME _libSALOME_Swig_d) diff --git a/src/SUIT/SUIT_LicenseDlg.cxx b/src/SUIT/SUIT_LicenseDlg.cxx index 85c29ef2b..6a2c7dbac 100755 --- a/src/SUIT/SUIT_LicenseDlg.cxx +++ b/src/SUIT/SUIT_LicenseDlg.cxx @@ -118,15 +118,18 @@ void SUIT_LicenseDlg::onAgree() { QString env; #ifdef WIN32 - DWORD aLen=1024; - char aStr[1024]; + DWORD aLen=1024; + TCHAR aStr[1024]; HANDLE aToken=0; HANDLE hProcess = GetCurrentProcess(); OpenProcessToken(hProcess,TOKEN_QUERY,&aToken); if( ! GetUserProfileDirectory( aToken, aStr, &aLen ) ) reject(); - +#ifdef UNICODE + env = QString::fromWCharArray(aStr); +#else env = aStr; +#endif #else if( ! ::getenv( "HOME" ) ) reject(); diff --git a/src/SUIT/SUIT_Session.cxx b/src/SUIT/SUIT_Session.cxx index 0fd4f37db..fa73419bf 100755 --- a/src/SUIT/SUIT_Session.cxx +++ b/src/SUIT/SUIT_Session.cxx @@ -324,7 +324,11 @@ QString SUIT_Session::lastError() const ::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, ::GetLastError(), 0, (LPTSTR)&lpMsgBuf, 0, 0 ); LPTSTR msg = (LPTSTR)lpMsgBuf; +#ifdef UNICODE + str = QString::fromWCharArray(msg); +#else str = QString( SUIT_Tools::toQString( msg ) ); +#endif LocalFree( lpMsgBuf ); #else str = QString( dlerror() ); diff --git a/src/SUITApp/SUITApp.cxx b/src/SUITApp/SUITApp.cxx index 75331cfa1..48df0f7e1 100644 --- a/src/SUITApp/SUITApp.cxx +++ b/src/SUITApp/SUITApp.cxx @@ -218,12 +218,17 @@ int main( int argc, char* argv[] ) #ifdef WIN32 DWORD aLen=1024; - char aStr[1024]; + TCHAR aStr[1024]; HANDLE aToken=0; HANDLE hProcess = GetCurrentProcess(); OpenProcessToken(hProcess,TOKEN_QUERY,&aToken); - if( GetUserProfileDirectory( aToken, aStr, &aLen ) ) - env = aStr; + if( GetUserProfileDirectory( aToken, aStr, &aLen ) ) { +#ifdef UNICODE + env = QString::fromWCharArray(aStr); +#else + env = aStr; +#endif + } #else if ( ::getenv( "HOME" ) ) diff --git a/src/VTKViewer/VTKViewer_OpenGLHelper.cxx b/src/VTKViewer/VTKViewer_OpenGLHelper.cxx index 7be1e8b88..d299db78e 100644 --- a/src/VTKViewer/VTKViewer_OpenGLHelper.cxx +++ b/src/VTKViewer/VTKViewer_OpenGLHelper.cxx @@ -71,6 +71,8 @@ VTKViewer_OpenGLHelper::VTKViewer_OpenGLHelper() vglBindVertexArrayARB (NULL), vglUniform1iARB (NULL), vglGetUniformLocationARB (NULL), + vglActiveTextureARB (NULL), + vglGetStringiARB (NULL), #endif mIsInitialized (false) { @@ -171,16 +173,24 @@ void VTKViewer_OpenGLHelper::Init() vglGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)GL_GetProcAddress( "glGetUniformLocationARB" ); if( !vglGetUniformLocationARB ) return; - - vglGetShaderivARB = (PFNGLGETSHADERIVPROC)GL_GetProcAddress( "glGetShaderiv" ); + + vglGetShaderivARB = (PFNGLGETSHADERIVARBPROC)GL_GetProcAddress( "glGetShaderiv" ); if( !vglGetShaderivARB ) return; - vglGetProgramivARB = (PFNGLGETPROGRAMIVPROC)GL_GetProcAddress( "glGetProgramiv" ); + vglActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)GL_GetProcAddress( "glActiveTexture" ); + if (!vglActiveTextureARB) + return; + + vglGetStringiARB = (PFNGLGETSTRINGIPROC)GL_GetProcAddress("glGetStringi"); + if (!vglGetStringiARB) + return; + + vglGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC)GL_GetProcAddress( "glGetProgramiv" ); if( !vglGetProgramivARB ) return; - vglGetShaderInfoLogARB = (PFNGLGETSHADERINFOLOGPROC)GL_GetProcAddress( "glGetShaderInfoLog" ); + vglGetShaderInfoLogARB = (PFNGLGETSHADERINFOLOGARBPROC)GL_GetProcAddress( "glGetShaderInfoLog" ); if( !vglGetShaderInfoLogARB ) return; @@ -269,7 +279,7 @@ bool VTKViewer_OpenGLHelper::CreateShaderProgram (const std::string& theFilePath if (compileStatus != GL_TRUE) { GLint size; - GLchar info[1024]; + GLcharARB info[1024]; vglGetShaderInfoLogARB (theVertexShader, 1024, &size, info); std::cerr << "Can't compile vertex shader." << std::endl; @@ -293,7 +303,7 @@ bool VTKViewer_OpenGLHelper::CreateShaderProgram (const std::string& theFilePath if (compileStatus != GL_TRUE) { GLint size; - GLchar info[1024]; + GLcharARB info[1024]; vglGetShaderInfoLogARB (theVertexShader, 1024, &size, info); std::cerr << "Can't compile fragment shader." << std::endl; diff --git a/src/VTKViewer/VTKViewer_OpenGLHelper.h b/src/VTKViewer/VTKViewer_OpenGLHelper.h index 4dd55b8f8..eee81950c 100644 --- a/src/VTKViewer/VTKViewer_OpenGLHelper.h +++ b/src/VTKViewer/VTKViewer_OpenGLHelper.h @@ -70,6 +70,33 @@ typedef ptrdiff_t GLsizeiptrARB; #define GL_STATIC_DRAW_ARB 0x88E4 #endif +#ifndef GL_COMPILE_STATUS +#define GL_COMPILE_STATUS 0x8B81 +#endif + +#ifndef GL_CURRENT_PROGRAM +#define GL_CURRENT_PROGRAM 0x8B8D +#endif + +#ifndef GL_DEBUG_TYPE_ERROR +#define GL_DEBUG_TYPE_ERROR 0x824C +#endif + +#ifndef GL_LINK_STATUS +#define GL_LINK_STATUS 0x8B82 +#endif + +#ifndef GL_TEXTURE0 +#define GL_TEXTURE0 0x84C0 +#endif + +#ifndef GL_VALIDATE_STATUS +#define GL_VALIDATE_STATUS 0x8B83 +#endif + +#ifndef GL_NUM_EXTENSIONS +#define GL_NUM_EXTENSIONS 0x821D +#endif namespace GUI_OPENGL { char* readFromFile( std::string fileName ); @@ -117,17 +144,19 @@ protected: typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); #ifdef VTK_OPENGL2 + typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB program); typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB program, const GLcharARB *name ); typedef void (APIENTRYP PFNGLGETSHADERIVARBPROC) (GLuint shader, GLenum pname, GLint *params); - typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLuint program, GLenum pname, GLint *params); - typedef void (APIENTRYP PFNGLGETSHADERINFOLOGARBPROC) (GLuint shader, GLsizei maxLength, GLsizei *length, GLchar *infoLog); + typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (APIENTRYP PFNGLGETSHADERINFOLOGARBPROC) (GLuint shader, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLGENVERTEXARRAYSARBPROC) (GLsizei n, GLuint *arrays); typedef void (APIENTRYP PFNGLBINDVERTEXARRAYARBPROC) (GLuint array); typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); + typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); #endif public: @@ -161,6 +190,8 @@ public: PFNGLBINDVERTEXARRAYARBPROC vglBindVertexArrayARB; PFNGLUNIFORM1IARBPROC vglUniform1iARB; PFNGLGETUNIFORMLOCATIONARBPROC vglGetUniformLocationARB; + PFNGLACTIVETEXTUREARBPROC vglActiveTextureARB; + PFNGLGETSTRINGIPROC vglGetStringiARB; #endif protected: diff --git a/src/VTKViewer/VTKViewer_PolyDataMapper.cxx b/src/VTKViewer/VTKViewer_PolyDataMapper.cxx index d6386fd7f..84f3dd8e6 100644 --- a/src/VTKViewer/VTKViewer_PolyDataMapper.cxx +++ b/src/VTKViewer/VTKViewer_PolyDataMapper.cxx @@ -104,7 +104,7 @@ void MessageCallback( GLenum source, GLuint id, GLenum severity, GLsizei length, - const GLchar* message, + const GLcharARB* message, const void* userParam ) { fprintf( stderr, "GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s\n", @@ -383,7 +383,7 @@ int VTKViewer_PolyDataMapper::InitExtensions() glGetIntegerv(GL_NUM_EXTENSIONS, &n); for (int i = 0; i < n; i++) { - const char *exti = (const char *)glGetStringi(GL_EXTENSIONS, i); + const char *exti = (const char *)this->OpenGLHelper.vglGetStringiARB(GL_EXTENSIONS, i); strm<< exti <<" "; } std::string s = strm.str(); @@ -447,7 +447,7 @@ void VTKViewer_PolyDataMapper::InitTextures() glGenTextures( 1, &this->PointSpriteTexture ); } #ifdef VTK_OPENGL2 - glActiveTexture( GL_TEXTURE0 ); + this->OpenGLHelper.vglActiveTextureARB( GL_TEXTURE0 ); #endif glBindTexture( GL_TEXTURE_2D, this->PointSpriteTexture ); glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE ); diff --git a/tools/RemoteFileBrowser/CMakeLists.txt b/tools/RemoteFileBrowser/CMakeLists.txt index 28b51be82..28c6a13df 100644 --- a/tools/RemoteFileBrowser/CMakeLists.txt +++ b/tools/RemoteFileBrowser/CMakeLists.txt @@ -55,9 +55,10 @@ SET(qremotefilebrowser_SOURCES ) SET(qremotefilebrowser_HEADERS - QRemoteFileBrowser - QRemoteCopyWidget - QMachineBrowser + QRemoteFileBrowser.h + QRemoteCopyWidget.h + QMachineBrowser.h + RemoteFileBrowser.h ) SET(qremotefilebrowser_LIBRARIES @@ -65,9 +66,9 @@ SET(qremotefilebrowser_LIBRARIES ) SET(_moc_HEADERS - QRemoteFileBrowser - QMachineBrowser - QRemoteCopyWidget + QRemoteFileBrowser.h + QMachineBrowser.h + QRemoteCopyWidget.h ) # sources / moc wrappings diff --git a/tools/RemoteFileBrowser/QMachineBrowser b/tools/RemoteFileBrowser/QMachineBrowser deleted file mode 100644 index f5c7f8520..000000000 --- a/tools/RemoteFileBrowser/QMachineBrowser +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2017 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// Author : Anthony GEAY (EDF R&D) - -#ifndef __QMACHINEBROWSER__ -#define __QMACHINEBROWSER__ - -#include -#include - -class QPushButton; -class QLineEdit; - -class QMachineSelector : public QComboBox -{ - Q_OBJECT -public: - QMachineSelector(QWidget *parent); - void initLocation(); -public slots: - void appendEntry(const QString& entry); -private: - void fillMachines(); - void fillMachinesFromCatalog(); - void fillMachinesFromSettings(); - void assignToLocalhost(); -}; - -class QMachineManager : public QWidget -{ - Q_OBJECT -public: - QMachineManager(QWidget *parent); - void initLocation(); - QString getSelectedHost() const; -public slots: - void newEntryRequested(); -private: - QPushButton *_pb; - QMachineSelector *_ms; -}; - -class QRemoteFileSystemModel; -class FileLoader; - -class QMachineBrowser : public QWidget -{ - Q_OBJECT -public: - QMachineBrowser(QWidget *parent=NULL); - void initLocation(); - QRemoteFileSystemModel *generateModel(); - FileLoader *generateFileLoader(); -signals: - void locationChanged(); -private: - QMachineManager *_msel; - QLineEdit *_le; -}; - -#endif diff --git a/tools/RemoteFileBrowser/QMachineBrowser.cxx b/tools/RemoteFileBrowser/QMachineBrowser.cxx index 9f5a65a8e..3cdf7027e 100644 --- a/tools/RemoteFileBrowser/QMachineBrowser.cxx +++ b/tools/RemoteFileBrowser/QMachineBrowser.cxx @@ -18,8 +18,8 @@ // // Author : Anthony GEAY (EDF R&D) -#include "QMachineBrowser" -#include "QRemoteFileBrowser" +#include "QMachineBrowser.h" +#include "QRemoteFileBrowser.h" #include "QDir" #include "QFileInfo" diff --git a/tools/RemoteFileBrowser/QMachineBrowser.h b/tools/RemoteFileBrowser/QMachineBrowser.h new file mode 100644 index 000000000..de17fa532 --- /dev/null +++ b/tools/RemoteFileBrowser/QMachineBrowser.h @@ -0,0 +1,79 @@ +// Copyright (C) 2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony GEAY (EDF R&D) + +#ifndef __QMACHINEBROWSER__ +#define __QMACHINEBROWSER__ + +#include "RemoteFileBrowser.h" + +#include +#include + +class QPushButton; +class QLineEdit; + +class QREMOTEFILEBROWSER_EXPORT QMachineSelector : public QComboBox +{ + Q_OBJECT +public: + QMachineSelector(QWidget *parent); + void initLocation(); +public slots: + void appendEntry(const QString& entry); +private: + void fillMachines(); + void fillMachinesFromCatalog(); + void fillMachinesFromSettings(); + void assignToLocalhost(); +}; + +class QREMOTEFILEBROWSER_EXPORT QMachineManager : public QWidget +{ + Q_OBJECT +public: + QMachineManager(QWidget *parent); + void initLocation(); + QString getSelectedHost() const; +public slots: + void newEntryRequested(); +private: + QPushButton *_pb; + QMachineSelector *_ms; +}; + +class QRemoteFileSystemModel; +class FileLoader; + +class QREMOTEFILEBROWSER_EXPORT QMachineBrowser : public QWidget +{ + Q_OBJECT +public: + QMachineBrowser(QWidget *parent=NULL); + void initLocation(); + QRemoteFileSystemModel *generateModel(); + FileLoader *generateFileLoader(); +signals: + void locationChanged(); +private: + QMachineManager *_msel; + QLineEdit *_le; +}; + +#endif diff --git a/tools/RemoteFileBrowser/QRemoteCopyWidget b/tools/RemoteFileBrowser/QRemoteCopyWidget deleted file mode 100644 index 4814b0a67..000000000 --- a/tools/RemoteFileBrowser/QRemoteCopyWidget +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (C) 2017 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// Author : Anthony GEAY (EDF R&D) - -#ifndef __QREMOTECOPYWIDGET__ -#define __QREMOTECOPYWIDGET__ - -#include "QDialog" -#include "QMutex" -#include "QThread" -#include "QTreeView" -#include "QTableView" -#include "QItemDelegate" -#include "QPointer" -#include "QProcess" - -class QRemoteFileSystemModel; -class QFilesDirsCopierModel; -class DataStructure; -class QTableView; - -void PerformCopy(QWidget *parent, QRemoteFileSystemModel *srcModel, const QModelIndexList& srcSelectedFiles, DataStructure *ds); - -class CopierThread : public QThread -{ -public: - CopierThread(QObject *parent, QFilesDirsCopierModel *model):QThread(parent),_model(model) { } - void stopRequested(); -protected: - void run(); -private: - QFilesDirsCopierModel *_model; -}; - -class QFilesDirsCopierModel : public QAbstractListModel -{ - Q_OBJECT -public: - QFilesDirsCopierModel(QObject *parent, const QList& srcFiles, DataStructure *destLoc); - int nbOfRows() const; - int rowCount(const QModelIndex&) const; - int columnCount(const QModelIndex&) const; - QVariant data(const QModelIndex&, int) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - const QString& getErrorStr() const { return _error; } - int getProgressOf(int srcFileId) const; - QString getFullNameOf(int srcFileId) const; - QString getNameOf(int srcFileId) const; - QString getPrettyText(int srcFileId) const; - QSize sizeHint() const; - // - void launchCopy(); - void stopCurrentCopy(); -public slots: - void newOutputAvailable(); -private: - void fillArgsForRSync(const DataStructure *srcFile, QStringList& args) const; -private: - QList _srcFiles; - // - mutable QMutex _mutOnProc; - volatile int _currentElt; - QPointer _curProc; - QString _error; - // - QVector _progress; - DataStructure *_destLoc; -public: - static constexpr int PROGRESS_STATUS_START=-1; - static constexpr int PROGRESS_STATUS_OVER=101; - static const char ATOMIC_STOP_MSG[]; -}; - -class ProgressDelegate : public QItemDelegate -{ -public: - ProgressDelegate(QObject *parent, QFilesDirsCopierModel *model):QItemDelegate(parent),_model(model) { } - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; -private: - QFilesDirsCopierModel *_model; -}; - -class CopierTableView : public QTableView -{ -public: - CopierTableView(QWidget *parent); - int sizeHintForColumn(int column) const; - int sizeHintForRow(int row) const; - void resizeEvent(QResizeEvent *event); - QSize sizeHint() const; -}; - -class FilesDirsCopier : public QDialog -{ - Q_OBJECT -public: - FilesDirsCopier(QWidget *parent, const QList& srcFiles, DataStructure *destLoc); -public slots: - void cancelRequested(); - void myAccept(bool); - int exec(); - const QString& getErrorStr() const { return _model->getErrorStr(); } -signals: - void myAcceptSignal(bool); -private: - CopierTableView *_table; - QPushButton *_cancel; - CopierThread *_th; - QFilesDirsCopierModel *_model; -}; - -#endif diff --git a/tools/RemoteFileBrowser/QRemoteCopyWidget.cxx b/tools/RemoteFileBrowser/QRemoteCopyWidget.cxx index 57b2137d1..934b985d9 100644 --- a/tools/RemoteFileBrowser/QRemoteCopyWidget.cxx +++ b/tools/RemoteFileBrowser/QRemoteCopyWidget.cxx @@ -18,8 +18,9 @@ // // Author : Anthony GEAY (EDF R&D) -#include "QRemoteCopyWidget" -#include "QRemoteFileBrowser" +#include "QRemoteCopyWidget.h" +#include "QRemoteFileBrowser.h" + #include "QVBoxLayout" #include "QPushButton" #include "QHeaderView" diff --git a/tools/RemoteFileBrowser/QRemoteCopyWidget.h b/tools/RemoteFileBrowser/QRemoteCopyWidget.h new file mode 100644 index 000000000..34dd1bd63 --- /dev/null +++ b/tools/RemoteFileBrowser/QRemoteCopyWidget.h @@ -0,0 +1,130 @@ +// Copyright (C) 2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony GEAY (EDF R&D) + +#ifndef __QREMOTECOPYWIDGET__ +#define __QREMOTECOPYWIDGET__ + +#include "RemoteFileBrowser.h" + +#include "QDialog" +#include "QMutex" +#include "QThread" +#include "QTreeView" +#include "QTableView" +#include "QItemDelegate" +#include "QPointer" +#include "QProcess" + +class QRemoteFileSystemModel; +class QFilesDirsCopierModel; +class DataStructure; +class QTableView; + +void PerformCopy(QWidget *parent, QRemoteFileSystemModel *srcModel, const QModelIndexList& srcSelectedFiles, DataStructure *ds); + +class QREMOTEFILEBROWSER_EXPORT CopierThread : public QThread +{ +public: + CopierThread(QObject *parent, QFilesDirsCopierModel *model):QThread(parent),_model(model) { } + void stopRequested(); +protected: + void run(); +private: + QFilesDirsCopierModel *_model; +}; + +class QREMOTEFILEBROWSER_EXPORT QFilesDirsCopierModel : public QAbstractListModel +{ + Q_OBJECT +public: + QFilesDirsCopierModel(QObject *parent, const QList& srcFiles, DataStructure *destLoc); + int nbOfRows() const; + int rowCount(const QModelIndex&) const; + int columnCount(const QModelIndex&) const; + QVariant data(const QModelIndex&, int) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + const QString& getErrorStr() const { return _error; } + int getProgressOf(int srcFileId) const; + QString getFullNameOf(int srcFileId) const; + QString getNameOf(int srcFileId) const; + QString getPrettyText(int srcFileId) const; + QSize sizeHint() const; + // + void launchCopy(); + void stopCurrentCopy(); +public slots: + void newOutputAvailable(); +private: + void fillArgsForRSync(const DataStructure *srcFile, QStringList& args) const; +private: + QList _srcFiles; + // + mutable QMutex _mutOnProc; + volatile int _currentElt; + QPointer _curProc; + QString _error; + // + QVector _progress; + DataStructure *_destLoc; +public: + static constexpr int PROGRESS_STATUS_START=-1; + static constexpr int PROGRESS_STATUS_OVER=101; + static const char ATOMIC_STOP_MSG[]; +}; + +class QREMOTEFILEBROWSER_EXPORT ProgressDelegate : public QItemDelegate +{ +public: + ProgressDelegate(QObject *parent, QFilesDirsCopierModel *model):QItemDelegate(parent),_model(model) { } + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; +private: + QFilesDirsCopierModel *_model; +}; + +class QREMOTEFILEBROWSER_EXPORT CopierTableView : public QTableView +{ +public: + CopierTableView(QWidget *parent); + int sizeHintForColumn(int column) const; + int sizeHintForRow(int row) const; + void resizeEvent(QResizeEvent *event); + QSize sizeHint() const; +}; + +class QREMOTEFILEBROWSER_EXPORT FilesDirsCopier : public QDialog +{ + Q_OBJECT +public: + FilesDirsCopier(QWidget *parent, const QList& srcFiles, DataStructure *destLoc); +public slots: + void cancelRequested(); + void myAccept(bool); + int exec(); + const QString& getErrorStr() const { return _model->getErrorStr(); } +signals: + void myAcceptSignal(bool); +private: + CopierTableView *_table; + QPushButton *_cancel; + CopierThread *_th; + QFilesDirsCopierModel *_model; +}; + +#endif diff --git a/tools/RemoteFileBrowser/QRemoteFileBrowser b/tools/RemoteFileBrowser/QRemoteFileBrowser deleted file mode 100644 index 6474a3342..000000000 --- a/tools/RemoteFileBrowser/QRemoteFileBrowser +++ /dev/null @@ -1,302 +0,0 @@ -// Copyright (C) 2017 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// Author : Anthony GEAY (EDF R&D) - -#ifndef __QREMOTEFILEBROWSER__ -#define __QREMOTEFILEBROWSER__ - -#include "QWidget" -#include "QTreeView" -#include "QMimeData" -#include "QThread" - -class AnotherTreeView; -class QMachineBrowser; -class QRemoteFileSystemModel; -class TopDirDataStructure; - -class LoadingThread : public QThread -{ - Q_OBJECT -public: - LoadingThread(QThread *th, QMachineBrowser *mb):_fatherThread(th),_mb(mb),_model(nullptr) { } - void setGeneratedModel(QRemoteFileSystemModel *model) { _model=model; } - QRemoteFileSystemModel *generatedModel() const { return _model; } -signals: - void letsGenerateModel(TopDirDataStructure *fds); -protected: - void run(); -private: - QThread *_fatherThread; - QMachineBrowser *_mb; - QRemoteFileSystemModel *_model; -}; - -class QRemoteFileBrowser : public QWidget -{ - Q_OBJECT -public: - QRemoteFileBrowser(QWidget *parent); - QMachineBrowser *machineBrower() const { return _mb; } -public slots: - void onLocationChanged(); - void locationHasBeenChanged(); -private: - AnotherTreeView *_treeView; - QMachineBrowser *_mb; -}; - -class QRemoteFileTransfer : public QWidget -{ -public: - QRemoteFileTransfer(QWidget *parent=0); -private: - QRemoteFileBrowser *_left; - QRemoteFileBrowser *_right; -}; - -class DirDataStructure; -class TopDirDataStructure; - -class DataStructure : public QObject -{ - Q_OBJECT -public: - DataStructure(QObject *parent, const QString& name):QObject(parent),_name(name),_selected(false) { } - void select() { _selected=true; } - void unselect() { _selected=false; } - bool isSelected() const { return _selected; } - virtual bool isFile() const = 0; - virtual QString nameOnDrop() const = 0; - const DirDataStructure *getDirParent() const; - bool isRoot() const { return getDirParent()==NULL; } - const TopDirDataStructure *getRoot() const; - std::vector getItermediateElts(const TopDirDataStructure *tpds) const; - virtual int size() const = 0; - QString entryForRSyncSrc() const; - virtual QString entryForRSyncDest() const = 0; - QString name() const; - const QString& fullName() const { return _name; } - void removeFileArgs(QString& prg, QStringList& args) const; -private: - QString _name; - bool _selected; -}; - -class FileDataStructure : public DataStructure -{ -public: - FileDataStructure(DirDataStructure *dds, const QString& name); - bool isFile() const { return true; } - int size() const { return 0; } - QString entryForRSyncDest() const; - QString nameOnDrop() const; -}; - -class DirDataStructure : public DataStructure -{ -public: - DirDataStructure(DirDataStructure *dds, const QString& name):DataStructure(dds,name),_is_loaded(false),_is_expanded(false) { } - DirDataStructure(QObject *dds, const QString& name):DataStructure(dds,name),_is_loaded(false) { } - bool isFile() const { return false; } - int size() const { load(); return children().size(); } - QString entryForRSyncDest() const; - QString nameOnDrop() const { return name(); } - const DataStructure *operator[](int pos) const; - int posOf(const DataStructure *ds) const; - bool load() const; - void markAsLoaded() const { _is_loaded=true; } - void setExpanded(bool status) { _is_expanded=status; } - bool isExpanded() const { return _is_expanded; } -private: - mutable bool _is_loaded; - mutable bool _is_expanded; -}; - -class FileLoader; - -class TopDirDataStructure : public DirDataStructure -{ -public: - TopDirDataStructure(QObject *dds, FileLoader *fl); - virtual ~TopDirDataStructure(); - FileLoader *getLoader() const { return _fl; } - bool isOK() const { return _isOK; } - QString entryForRSync(const QString& fn) const; - QString getMachine() const; - void removeFileArgsImpl(const QString& filePath, QString& prg, QStringList& args) const; -private: - FileLoader *_fl; - bool _isOK; -}; - -class QRemoteFileSystemModel; - -class MyTreeView : public QTreeView -{ - Q_OBJECT -public: - MyTreeView(QWidget *parent); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void keyPressEvent(QKeyEvent *event); - void dragEnterEvent(QDragEnterEvent *event); - void dragMoveEvent(QDragMoveEvent *event); - void dragLeaveEvent(QDragLeaveEvent *event); - void dropEvent(QDropEvent *event); - QRemoteFileSystemModel *zeModel(); - void emitResetModel(); -public slots: - void itemExpanded(const QModelIndex &index); - void itemCollapsed(const QModelIndex &index); -signals: - void somethingChangedDueToFileModif(); -private: - void itemExpandedStatus(const QModelIndex &index, bool status); - void drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const; - void paintEvent(QPaintEvent *event); -private: - QPoint _start_pos; - // during drag drop _sel is the element under the mouse on the drop site - DataStructure *_sel; - // during drag drop _slider_pos is the pos of vertical slider on drop site - int _slider_pos; -}; - -class AnotherTreeView; - -class AnotherTreeViewPainter -{ -public: - virtual void paint(AnotherTreeView *atv, QPaintEvent *event) const = 0; -}; - -class AnotherTreeViewWaitPainter : public AnotherTreeViewPainter -{ -public: - void paint(AnotherTreeView *atv, QPaintEvent *event) const; -}; - -class AnotherTreeViewNothingPainter : public AnotherTreeViewPainter -{ -public: - void paint(AnotherTreeView *atv, QPaintEvent *event) const; -}; - -class AnotherTreeView : public QWidget -{ - Q_OBJECT -public: - AnotherTreeView(QWidget *parent); - void generateModel(QMachineBrowser *mb); - QSize sizeHint() const; - QSize minimumSizeHint() const; - int getAngle() const { return _angle; } - ~AnotherTreeView(); -public slots: - void goGenerate(TopDirDataStructure *fds); - void modelHasBeenGenerated(); -signals: - void modelHasBeenGeneratedSignal(bool isOK); - void somethingChangedDueToFileModif(); -protected: - void paintEvent(QPaintEvent *event); - void timerEvent(QTimerEvent *e); -private: - int _timerId; - int _angle; - AnotherTreeViewPainter *_painter; - MyTreeView *_tw; - LoadingThread *_th; -}; - -class FileLoader -{ -protected: - FileLoader(const QString& dirName):_dirName(dirName) { } -public: - QString getDirName() const { return _dirName; } - virtual bool load(DirDataStructure *parent) const = 0; - virtual QString prettyPrint() const = 0; - virtual QString entryForRSync(const QString& fn) const = 0; - virtual QString getMachine() const = 0; - virtual void removeFileArgs(const QString& filePath, QString& prg, QStringList& args) const = 0; - virtual ~FileLoader() { } -private: - QString _dirName; -}; - -class LocalFileLoader : public FileLoader -{ -public: - LocalFileLoader(const QString& dirName):FileLoader(dirName) { } - bool load(DirDataStructure *parent) const; - void fillArgs(const QString& dn, QString& prg, QStringList& args) const; - QString prettyPrint() const; - QString entryForRSync(const QString& fn) const; - QString getMachine() const; - void removeFileArgs(const QString& filePath, QString& prg, QStringList& args) const; -}; - -class RemoteFileLoader : public FileLoader -{ -public: - RemoteFileLoader(const QString& machine,const QString& dirName):FileLoader(dirName),_machine(machine) { } - bool load(DirDataStructure *parent) const; - void fillArgs(const QString& dn, QString& prg, QStringList& args) const; - QString prettyPrint() const; - QString entryForRSync(const QString& fn) const; - QString getMachine() const; - void removeFileArgs(const QString& filePath, QString& prg, QStringList& args) const; -private: - QString _machine; -}; - -class SelectionMimeData : public QMimeData -{ - Q_OBJECT -public: - SelectionMimeData(const QModelIndexList& los):_los(los) { } - const QModelIndexList& getSelection() const { return _los; } -private: - QModelIndexList _los; -}; - -class QRemoteFileSystemModel : public QAbstractItemModel -{ - Q_OBJECT -public: - QRemoteFileSystemModel(QObject *parent, FileLoader *fl); - QRemoteFileSystemModel(QObject *parent, TopDirDataStructure *fds); - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - QModelIndex parent(const QModelIndex&) const; - QModelIndex index(int, int, const QModelIndex&) const; - int rowCount(const QModelIndex&) const; - int columnCount(const QModelIndex&) const; - QVariant data(const QModelIndex&, int) const; - void emitResetModel(); - FileLoader *getLoader() const { return _fds->getLoader(); } - bool isOK() const { return _fds->isOK(); } - QString getMachine() const { return _fds->getMachine(); } -private: - TopDirDataStructure *_fds; -}; - -#endif diff --git a/tools/RemoteFileBrowser/QRemoteFileBrowser.cxx b/tools/RemoteFileBrowser/QRemoteFileBrowser.cxx index 8d28a8eae..ee5e55605 100644 --- a/tools/RemoteFileBrowser/QRemoteFileBrowser.cxx +++ b/tools/RemoteFileBrowser/QRemoteFileBrowser.cxx @@ -18,9 +18,9 @@ // // Author : Anthony GEAY (EDF R&D) -#include "QRemoteFileBrowser" -#include "QMachineBrowser" -#include "QRemoteCopyWidget" +#include "QRemoteFileBrowser.h" +#include "QMachineBrowser.h" +#include "QRemoteCopyWidget.h" #include "QDirModel" #include "QFileSystemModel" diff --git a/tools/RemoteFileBrowser/QRemoteFileBrowser.h b/tools/RemoteFileBrowser/QRemoteFileBrowser.h new file mode 100644 index 000000000..9f013d8c2 --- /dev/null +++ b/tools/RemoteFileBrowser/QRemoteFileBrowser.h @@ -0,0 +1,304 @@ +// Copyright (C) 2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony GEAY (EDF R&D) + +#ifndef __QREMOTEFILEBROWSER__ +#define __QREMOTEFILEBROWSER__ + +#include "RemoteFileBrowser.h" + +#include "QWidget" +#include "QTreeView" +#include "QMimeData" +#include "QThread" + +class AnotherTreeView; +class QMachineBrowser; +class QRemoteFileSystemModel; +class TopDirDataStructure; + +class QREMOTEFILEBROWSER_EXPORT LoadingThread : public QThread +{ + Q_OBJECT +public: + LoadingThread(QThread *th, QMachineBrowser *mb):_fatherThread(th),_mb(mb),_model(nullptr) { } + void setGeneratedModel(QRemoteFileSystemModel *model) { _model=model; } + QRemoteFileSystemModel *generatedModel() const { return _model; } +signals: + void letsGenerateModel(TopDirDataStructure *fds); +protected: + void run(); +private: + QThread *_fatherThread; + QMachineBrowser *_mb; + QRemoteFileSystemModel *_model; +}; + +class QREMOTEFILEBROWSER_EXPORT QRemoteFileBrowser : public QWidget +{ + Q_OBJECT +public: + QRemoteFileBrowser(QWidget *parent); + QMachineBrowser *machineBrower() const { return _mb; } +public slots: + void onLocationChanged(); + void locationHasBeenChanged(); +private: + AnotherTreeView *_treeView; + QMachineBrowser *_mb; +}; + +class QREMOTEFILEBROWSER_EXPORT QRemoteFileTransfer : public QWidget +{ +public: + QRemoteFileTransfer(QWidget *parent=0); +private: + QRemoteFileBrowser *_left; + QRemoteFileBrowser *_right; +}; + +class DirDataStructure; +class TopDirDataStructure; + +class QREMOTEFILEBROWSER_EXPORT DataStructure : public QObject +{ + Q_OBJECT +public: + DataStructure(QObject *parent, const QString& name):QObject(parent),_name(name),_selected(false) { } + void select() { _selected=true; } + void unselect() { _selected=false; } + bool isSelected() const { return _selected; } + virtual bool isFile() const = 0; + virtual QString nameOnDrop() const = 0; + const DirDataStructure *getDirParent() const; + bool isRoot() const { return getDirParent()==NULL; } + const TopDirDataStructure *getRoot() const; + std::vector getItermediateElts(const TopDirDataStructure *tpds) const; + virtual int size() const = 0; + QString entryForRSyncSrc() const; + virtual QString entryForRSyncDest() const = 0; + QString name() const; + const QString& fullName() const { return _name; } + void removeFileArgs(QString& prg, QStringList& args) const; +private: + QString _name; + bool _selected; +}; + +class QREMOTEFILEBROWSER_EXPORT FileDataStructure : public DataStructure +{ +public: + FileDataStructure(DirDataStructure *dds, const QString& name); + bool isFile() const { return true; } + int size() const { return 0; } + QString entryForRSyncDest() const; + QString nameOnDrop() const; +}; + +class QREMOTEFILEBROWSER_EXPORT DirDataStructure : public DataStructure +{ +public: + DirDataStructure(DirDataStructure *dds, const QString& name):DataStructure(dds,name),_is_loaded(false),_is_expanded(false) { } + DirDataStructure(QObject *dds, const QString& name):DataStructure(dds,name),_is_loaded(false) { } + bool isFile() const { return false; } + int size() const { load(); return children().size(); } + QString entryForRSyncDest() const; + QString nameOnDrop() const { return name(); } + const DataStructure *operator[](int pos) const; + int posOf(const DataStructure *ds) const; + bool load() const; + void markAsLoaded() const { _is_loaded=true; } + void setExpanded(bool status) { _is_expanded=status; } + bool isExpanded() const { return _is_expanded; } +private: + mutable bool _is_loaded; + mutable bool _is_expanded; +}; + +class FileLoader; + +class QREMOTEFILEBROWSER_EXPORT TopDirDataStructure : public DirDataStructure +{ +public: + TopDirDataStructure(QObject *dds, FileLoader *fl); + virtual ~TopDirDataStructure(); + FileLoader *getLoader() const { return _fl; } + bool isOK() const { return _isOK; } + QString entryForRSync(const QString& fn) const; + QString getMachine() const; + void removeFileArgsImpl(const QString& filePath, QString& prg, QStringList& args) const; +private: + FileLoader *_fl; + bool _isOK; +}; + +class QRemoteFileSystemModel; + +class QREMOTEFILEBROWSER_EXPORT MyTreeView : public QTreeView +{ + Q_OBJECT +public: + MyTreeView(QWidget *parent); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void keyPressEvent(QKeyEvent *event); + void dragEnterEvent(QDragEnterEvent *event); + void dragMoveEvent(QDragMoveEvent *event); + void dragLeaveEvent(QDragLeaveEvent *event); + void dropEvent(QDropEvent *event); + QRemoteFileSystemModel *zeModel(); + void emitResetModel(); +public slots: + void itemExpanded(const QModelIndex &index); + void itemCollapsed(const QModelIndex &index); +signals: + void somethingChangedDueToFileModif(); +private: + void itemExpandedStatus(const QModelIndex &index, bool status); + void drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const; + void paintEvent(QPaintEvent *event); +private: + QPoint _start_pos; + // during drag drop _sel is the element under the mouse on the drop site + DataStructure *_sel; + // during drag drop _slider_pos is the pos of vertical slider on drop site + int _slider_pos; +}; + +class AnotherTreeView; + +class QREMOTEFILEBROWSER_EXPORT AnotherTreeViewPainter +{ +public: + virtual void paint(AnotherTreeView *atv, QPaintEvent *event) const = 0; +}; + +class QREMOTEFILEBROWSER_EXPORT AnotherTreeViewWaitPainter : public AnotherTreeViewPainter +{ +public: + void paint(AnotherTreeView *atv, QPaintEvent *event) const; +}; + +class QREMOTEFILEBROWSER_EXPORT AnotherTreeViewNothingPainter : public AnotherTreeViewPainter +{ +public: + void paint(AnotherTreeView *atv, QPaintEvent *event) const; +}; + +class QREMOTEFILEBROWSER_EXPORT AnotherTreeView : public QWidget +{ + Q_OBJECT +public: + AnotherTreeView(QWidget *parent); + void generateModel(QMachineBrowser *mb); + QSize sizeHint() const; + QSize minimumSizeHint() const; + int getAngle() const { return _angle; } + ~AnotherTreeView(); +public slots: + void goGenerate(TopDirDataStructure *fds); + void modelHasBeenGenerated(); +signals: + void modelHasBeenGeneratedSignal(bool isOK); + void somethingChangedDueToFileModif(); +protected: + void paintEvent(QPaintEvent *event); + void timerEvent(QTimerEvent *e); +private: + int _timerId; + int _angle; + AnotherTreeViewPainter *_painter; + MyTreeView *_tw; + LoadingThread *_th; +}; + +class QREMOTEFILEBROWSER_EXPORT FileLoader +{ +protected: + FileLoader(const QString& dirName):_dirName(dirName) { } +public: + QString getDirName() const { return _dirName; } + virtual bool load(DirDataStructure *parent) const = 0; + virtual QString prettyPrint() const = 0; + virtual QString entryForRSync(const QString& fn) const = 0; + virtual QString getMachine() const = 0; + virtual void removeFileArgs(const QString& filePath, QString& prg, QStringList& args) const = 0; + virtual ~FileLoader() { } +private: + QString _dirName; +}; + +class QREMOTEFILEBROWSER_EXPORT LocalFileLoader : public FileLoader +{ +public: + LocalFileLoader(const QString& dirName):FileLoader(dirName) { } + bool load(DirDataStructure *parent) const; + void fillArgs(const QString& dn, QString& prg, QStringList& args) const; + QString prettyPrint() const; + QString entryForRSync(const QString& fn) const; + QString getMachine() const; + void removeFileArgs(const QString& filePath, QString& prg, QStringList& args) const; +}; + +class QREMOTEFILEBROWSER_EXPORT RemoteFileLoader : public FileLoader +{ +public: + RemoteFileLoader(const QString& machine,const QString& dirName):FileLoader(dirName),_machine(machine) { } + bool load(DirDataStructure *parent) const; + void fillArgs(const QString& dn, QString& prg, QStringList& args) const; + QString prettyPrint() const; + QString entryForRSync(const QString& fn) const; + QString getMachine() const; + void removeFileArgs(const QString& filePath, QString& prg, QStringList& args) const; +private: + QString _machine; +}; + +class QREMOTEFILEBROWSER_EXPORT SelectionMimeData : public QMimeData +{ + Q_OBJECT +public: + SelectionMimeData(const QModelIndexList& los):_los(los) { } + const QModelIndexList& getSelection() const { return _los; } +private: + QModelIndexList _los; +}; + +class QREMOTEFILEBROWSER_EXPORT QRemoteFileSystemModel : public QAbstractItemModel +{ + Q_OBJECT +public: + QRemoteFileSystemModel(QObject *parent, FileLoader *fl); + QRemoteFileSystemModel(QObject *parent, TopDirDataStructure *fds); + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QModelIndex parent(const QModelIndex&) const; + QModelIndex index(int, int, const QModelIndex&) const; + int rowCount(const QModelIndex&) const; + int columnCount(const QModelIndex&) const; + QVariant data(const QModelIndex&, int) const; + void emitResetModel(); + FileLoader *getLoader() const { return _fds->getLoader(); } + bool isOK() const { return _fds->isOK(); } + QString getMachine() const { return _fds->getMachine(); } +private: + TopDirDataStructure *_fds; +}; + +#endif diff --git a/tools/RemoteFileBrowser/RemoteFileBrowser.h b/tools/RemoteFileBrowser/RemoteFileBrowser.h new file mode 100644 index 000000000..dcc73ff58 --- /dev/null +++ b/tools/RemoteFileBrowser/RemoteFileBrowser.h @@ -0,0 +1,36 @@ +// Copyright (C) 2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony GEAY (EDF R&D) + +#if !defined ( REMOTE_FILE_BROWSER_H ) +#define REMOTE_FILE_BROWSER_H + +// ======================================================== +// set dllexport type for Win platform +#ifdef WIN32 +# if defined QREMOTEFILEBROWSER_EXPORTS || defined qremotefilebrowser_EXPORTS +# define QREMOTEFILEBROWSER_EXPORT __declspec(dllexport) +# else +# define QREMOTEFILEBROWSER_EXPORT __declspec(dllimport) +# endif +#else // WIN32 +# define PYINTERP_EXPORT +#endif // WIN32 + +#endif //REMOTE_FILE_BROWSER_H \ No newline at end of file diff --git a/tools/RemoteFileBrowser/remotefilebrowser.cxx b/tools/RemoteFileBrowser/remotefilebrowser.cxx index af7c57416..97cb01d5b 100644 --- a/tools/RemoteFileBrowser/remotefilebrowser.cxx +++ b/tools/RemoteFileBrowser/remotefilebrowser.cxx @@ -19,7 +19,7 @@ // Author : Anthony GEAY (EDF R&D) #include "QApplication" -#include "QRemoteFileBrowser" +#include "QRemoteFileBrowser.h" int main(int argc, char *argv[]) {