From fb157af3c130d252d39bbc26498e8753f3e84d50 Mon Sep 17 00:00:00 2001
From: Gennady Pospelov <g.pospelov@fz-juelich.de>
Date: Thu, 19 Sep 2013 16:51:16 +0200
Subject: [PATCH] GUI is compiled under Windows

---
 Core/Geometry/inc/BasicVector3D.h                   |  5 +++++
 GUI/CMakeLists.txt                                  |  2 ++
 GUI/coregui/CMakeLists.txt                          |  5 +++--
 .../SampleDesigner/MaterialBrowserModel.cpp         |  7 +++++--
 GUI/externals/qt-manhattan-style/CMakeLists.txt     |  1 +
 GUI/externals/qt-root-gui-factory/CMakeLists.txt    |  7 ++++---
 GUI/externals/qt-root/CMakeLists.txt                |  4 +++-
 GUI/externals/qt-root/src/TGQt.cxx                  |  4 ++--
 GUI/externals/qt-root/src/TQtApplication.cxx        | 11 +++++++----
 GUI/externals/qt-root/src/TQtWidget.cxx             | 13 ++++++++++---
 cmake/modules/FindROOT.cmake                        |  2 +-
 cmake/modules/SearchInstalledSoftware.cmake         |  2 ++
 12 files changed, 45 insertions(+), 18 deletions(-)

diff --git a/Core/Geometry/inc/BasicVector3D.h b/Core/Geometry/inc/BasicVector3D.h
index 302b5c08677..19657989418 100644
--- a/Core/Geometry/inc/BasicVector3D.h
+++ b/Core/Geometry/inc/BasicVector3D.h
@@ -350,6 +350,11 @@ template<> BA_CORE_API_ BasicVector3D<double> BasicVector3D<double>::cross(
         const BasicVector3D<double>& v) const;
 
 
+template<> BA_CORE_API_ double BasicVector3D<double>::phi() const;
+
+template<> BA_CORE_API_ double BasicVector3D<double>::theta() const;
+
+
 }  // namespace Geometry
 
 #endif /* GEOMETRY_BASICVECTOR3D_H */
diff --git a/GUI/CMakeLists.txt b/GUI/CMakeLists.txt
index 23ba90e4baa..b482f0b6c7c 100644
--- a/GUI/CMakeLists.txt
+++ b/GUI/CMakeLists.txt
@@ -4,6 +4,8 @@
 
 cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
 
+cmake_policy(SET CMP0020 NEW)
+
 find_package(Qt5Widgets REQUIRED)
 
 add_subdirectory(externals/qt-manhattan-style)
diff --git a/GUI/coregui/CMakeLists.txt b/GUI/coregui/CMakeLists.txt
index 73527ec6cc8..7cd9a0a0f04 100644
--- a/GUI/coregui/CMakeLists.txt
+++ b/GUI/coregui/CMakeLists.txt
@@ -4,6 +4,8 @@
 
 cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
 
+cmake_policy(SET CMP0020 NEW)
+
 set(executable_name coregui)
 
 # --- source and include files ---
@@ -72,6 +74,7 @@ add_executable(${executable_name} ${source_files} ${RC_SRCS} ${include_files})
 
 # --- dependencies ---
 include_directories(
+    ${Boost_INCLUDE_DIRS}
     ${BornAgainCore_INCLUDE_DIRS}
     ${BornAgainFit_INCLUDE_DIRS}
     ${ROOT_INCLUDE_DIR}
@@ -98,8 +101,6 @@ target_link_libraries(${executable_name}
     ${QtRoot_LIBRARY}
 )
 
-message("XXX ${ROOT_LIBRARIES}")
-
 #core gui script webkit webkitwidgets designer designercomponents
 qt5_use_modules(${executable_name} Widgets Core Gui Script WebKit WebKitWidgets Designer)
 
diff --git a/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserModel.cpp b/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserModel.cpp
index 345873d0eda..65648b337f1 100644
--- a/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserModel.cpp
+++ b/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserModel.cpp
@@ -4,6 +4,7 @@
 #include "HomogeneousMaterial.h"
 #include <QColor>
 #include <QtScript>
+#include "Types.h"
 
 
 #if QT_VERSION < 0x050000
@@ -172,7 +173,7 @@ bool MaterialBrowserModel::setData(const QModelIndex & index, const QVariant & v
                 return false;
             }
             refractiveIndex = mat->getRefractiveIndex();
-            refractiveIndex.real() = double_value;
+            refractiveIndex = complex_t(double_value, refractiveIndex.imag());
             status = MaterialManager::instance().setMaterialRefractiveIndex(mat->getName(), refractiveIndex);
             if(!status) {
                 emit SetDataMessage("Can't set given value of RefractiveIndex");
@@ -190,7 +191,9 @@ bool MaterialBrowserModel::setData(const QModelIndex & index, const QVariant & v
                 return false;
             }
             refractiveIndex = mat->getRefractiveIndex();
-            refractiveIndex.imag() = double_value;
+            //refractiveIndex.imag()=double_value;
+            //refractiveIndex.imag(double_value);
+            refractiveIndex = complex_t(refractiveIndex.real(), double_value);
             status = MaterialManager::instance().setMaterialRefractiveIndex(mat->getName(), refractiveIndex);
             if(!status) {
                 emit SetDataMessage("Can't set given value of RefractiveIndex");
diff --git a/GUI/externals/qt-manhattan-style/CMakeLists.txt b/GUI/externals/qt-manhattan-style/CMakeLists.txt
index eaf7a631551..56c6736d5cf 100644
--- a/GUI/externals/qt-manhattan-style/CMakeLists.txt
+++ b/GUI/externals/qt-manhattan-style/CMakeLists.txt
@@ -3,6 +3,7 @@
 ############################################################################
 
 cmake_minimum_required(VERSION 2.8.9)
+cmake_policy(SET CMP0020 NEW)
 
 #project(qt-manhattan-style)
 set(library_name ManhattanStyle)
diff --git a/GUI/externals/qt-root-gui-factory/CMakeLists.txt b/GUI/externals/qt-root-gui-factory/CMakeLists.txt
index 62a5c6e3368..a76b4115742 100644
--- a/GUI/externals/qt-root-gui-factory/CMakeLists.txt
+++ b/GUI/externals/qt-root-gui-factory/CMakeLists.txt
@@ -3,6 +3,8 @@
 ############################################################################
 
 cmake_minimum_required(VERSION 2.8.9)
+cmake_policy(SET CMP0020 NEW)
+
 set(library_name QtRoot)
 
 # source files
@@ -17,7 +19,7 @@ ROOT_GENERATE_DICTIONARY(G__QtRoot ${include_files} LINKDEF LinkDef.h)
 # --- making library ---
 add_library(
     ${library_name}
-    SHARED
+    STATIC
     ${source_files} ${include_files} G__QtRoot.cxx
 )
 set(${library_name}_INCLUDE_DIRS ${include_dirs} PARENT_SCOPE)
@@ -29,8 +31,7 @@ include_directories(
     ${GQt_INCLUDE_DIRS}
 )
 
-message("YYY ${ROOT_LIBRARIES}")
-target_link_libraries(${library_name} ${ROOT_LIBRARIES})
+target_link_libraries(${library_name} ${ROOT_LIBRARIES} ${GQt_LIBRARY})
 
 #find_package(Qt5Widgets REQUIRED)
 qt5_use_modules(${library_name} Widgets)
diff --git a/GUI/externals/qt-root/CMakeLists.txt b/GUI/externals/qt-root/CMakeLists.txt
index 758be6b4d1e..f42f03202a7 100644
--- a/GUI/externals/qt-root/CMakeLists.txt
+++ b/GUI/externals/qt-root/CMakeLists.txt
@@ -3,6 +3,8 @@
 ############################################################################
 
 cmake_minimum_required(VERSION 2.8.9)
+cmake_policy(SET CMP0020 NEW)
+
 set(library_name GQt)
 
 # source files
@@ -29,7 +31,7 @@ ROOT_GENERATE_DICTIONARY(AppDict    inc/DrawHelper.h inc/TreeEventStructure.h  L
 # --- making library ---
 add_library(
     ${library_name}
-    SHARED
+    STATIC
     ${source_files} ${include_files} ${mocfiles} G__GQt.cxx
 )
 set(${library_name}_INCLUDE_DIRS ${include_dirs} PARENT_SCOPE)
diff --git a/GUI/externals/qt-root/src/TGQt.cxx b/GUI/externals/qt-root/src/TGQt.cxx
index c43b77740d1..a0fc31378cf 100644
--- a/GUI/externals/qt-root/src/TGQt.cxx
+++ b/GUI/externals/qt-root/src/TGQt.cxx
@@ -1026,7 +1026,7 @@ Bool_t TGQt::Init(void* /*display*/)
          QString libPath = gSystem->GetLinkedLibs();
          // detect the exact name of the Qt library
          TString qtlibdir= "$(QTDIR)";
-         qtlibdir += QDir::separator().toAscii();
+         qtlibdir += QDir::separator().toLatin1();
          qtlibdir += "lib";
 
          gSystem->ExpandPathName(qtlibdir);
@@ -1046,7 +1046,7 @@ Bool_t TGQt::Init(void* /*display*/)
 #else
                   libPath += "QtCore4.lib QtGui4.lib QtOpenGL4.lib Qt3Support4.lib";
 #endif
-               gSystem->SetLinkedLibs(libPath.toAscii().data());
+               gSystem->SetLinkedLibs(libPath.toStdString().c_str());
             }
          } else {
             qWarning(" Can not open the QTDIR %s",(const char*)qtlibdir);
diff --git a/GUI/externals/qt-root/src/TQtApplication.cxx b/GUI/externals/qt-root/src/TQtApplication.cxx
index a246b3ab673..b82c04241a8 100644
--- a/GUI/externals/qt-root/src/TQtApplication.cxx
+++ b/GUI/externals/qt-root/src/TQtApplication.cxx
@@ -57,6 +57,7 @@ TQtApplication::TQtApplication(const char * /*appClassName*/, int &argc,char **a
 //______________________________________________________________________________
 TQtApplication::~TQtApplication()
 { }
+#include <iostream>
 //______________________________________________________________________________
 void TQtApplication::CreateQApplication(int &argc, char ** argv, bool GUIenabled)
 {
@@ -126,10 +127,12 @@ void TQtApplication::CreateQApplication(int &argc, char ** argv, bool GUIenabled
    }
   
    // Add Qt plugin path if  present (it is the case for Windows binary ROOT distribution)
-   char *qtPluginPath = gSystem->ConcatFileName(gSystem->Getenv("ROOTSYS"),"/Qt/plugins");
-   if (!gSystem->AccessPathName(qtPluginPath))
-       qApp->addLibraryPath(qtPluginPath);
-   delete [] qtPluginPath;
+   // FIXME I have commented this code 19.09.2013, program was crashing
+//   char *qtPluginPath = gSystem->ConcatFileName(gSystem->Getenv("ROOTSYS"),"/Qt/plugins");
+//   std::cout << "XXXXX qtPluginPath" << qtPluginPath << std::endl;
+//   if (!gSystem->AccessPathName(qtPluginPath))
+//       qApp->addLibraryPath(qtPluginPath);
+//   delete [] qtPluginPath;
 }
 //______________________________________________________________________________
 void TQtApplication::CreateGUIThread(int &argc, char **argv)
diff --git a/GUI/externals/qt-root/src/TQtWidget.cxx b/GUI/externals/qt-root/src/TQtWidget.cxx
index af9fc674802..546867dfa04 100644
--- a/GUI/externals/qt-root/src/TQtWidget.cxx
+++ b/GUI/externals/qt-root/src/TQtWidget.cxx
@@ -26,9 +26,11 @@
 #  include <QDebug>
 #endif /* QT_VERSION */
 
-# if QT_VERSION >= 0x40000 and QT_VERSION <0x50000
+# if QT_VERSION >= 0x40000 
+# if QT_VERSION <0x50000
 #  include <QCustomEvent>
 #endif
+#endif
 
 
 #include "TQtWidget.h"
@@ -240,10 +242,15 @@ void TQtWidget::Init()
       HICON hIcon = ::LoadIcon(::GetModuleHandle(NULL), MAKEINTRESOURCE(101));
       if (!hIcon) hIcon = LoadIcon(NULL, IDI_APPLICATION);
       rootIcon = hIcon;
-      SetClassLong(winId(),        // handle to window
+//      SetClassLong(winId(),        // handle to window
+//                   GCL_HICON,      // index of value to change
+//                   LONG(rootIcon)  // new value
+//      );
+      SetClassLongPtr((HWND)winId(),        // handle to window
                    GCL_HICON,      // index of value to change
                    LONG(rootIcon)  // new value
       );
+
     }
 #endif
 }
@@ -739,7 +746,7 @@ void TQtWidget::resizeEvent(QResizeEvent *e)
       if (!fPaint)  {
          // real resize event
          fSizeChanged=kTRUE;
-         fNeedStretch=ktrue;
+         fNeedStretch=kTRUE;
       } else {
 #else
       {
diff --git a/cmake/modules/FindROOT.cmake b/cmake/modules/FindROOT.cmake
index 006979a27c8..415b3c7bc5c 100644
--- a/cmake/modules/FindROOT.cmake
+++ b/cmake/modules/FindROOT.cmake
@@ -20,7 +20,7 @@ else()
         set(ROOT_INCLUDE_DIR ${ROOTSYS}/include)
         set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib)
         #set(ROOT_LIBRARIES -LIBPATH:${ROOT_LIBRARY_DIR} libGpad.lib libHist.lib libGraf.lib libGraf3d.lib libTree.lib libRint.lib libPostscript.lib libMatrix.lib libPhysics.lib libMathCore.lib libRIO.lib libNet.lib libThread.lib libCore.lib libCint.lib)
-        set(ROOT_LIBRARIES -LIBPATH:${ROOT_LIBRARY_DIR} libGpad.lib libHist.lib libGraf.lib libGraf3d.lib libTree.lib libRint.lib libPostscript.lib libMatrix.lib libMathCore.lib libRIO.lib libNet.lib libThread.lib libCore.lib libCint.lib)
+        set(ROOT_LIBRARIES -LIBPATH:${ROOT_LIBRARY_DIR} libGui.lib libGpad.lib libHist.lib libGraf.lib libGraf3d.lib libTree.lib libRint.lib libPostscript.lib libMatrix.lib libMathCore.lib libRIO.lib libNet.lib libThread.lib libCore.lib libCint.lib)
     else()
 
         execute_process(
diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake
index c102fe45939..f28c67d31a0 100644
--- a/cmake/modules/SearchInstalledSoftware.cmake
+++ b/cmake/modules/SearchInstalledSoftware.cmake
@@ -67,6 +67,8 @@ if(BORNAGAIN_PYTHON OR BORNAGAIN_GUI)
     endif()
     find_package(Numpy REQUIRED)
 endif()
+message("XXX ${PYTHON_LIBRARIES}")
+
 
 # --- ROOT ---
 find_package(ROOT)
-- 
GitLab