]> Creatis software - clitk.git/commitdiff
Fix for retina display
authorSimon Rit <simon.rit@creatis.insa-lyon.fr>
Tue, 16 Feb 2016 21:39:21 +0000 (22:39 +0100)
committerSimon Rit <simon.rit@creatis.insa-lyon.fr>
Tue, 16 Feb 2016 21:39:21 +0000 (22:39 +0100)
http://public.kitware.com/pipermail/vtkusers/2015-February/090117.html

vv/CMakeLists.txt
vv/vvMainWindow.cxx
vv/vvOSXHelper.h [new file with mode: 0644]
vv/vvOSXHelper.mm [new file with mode: 0644]

index 1d28f84d1c0096279fb66be24be3c3ca2207c68c..c61497546f75320380adbb17de22be78d44e2c5e 100644 (file)
@@ -111,158 +111,157 @@ set(vv_SRCS
 #=========================================================
 # Qt related commands
 if(vv_QT_VERSION VERSION_GREATER "4")
-find_package(Qt5Widgets REQUIRED)
-find_package(Qt5Network REQUIRED)
-find_package(Qt5Designer REQUIRED)
-link_directories(${QT5Widgets_LIBRARIES})
-link_directories(${QT5Network_LIBRARIES})
-link_directories(${QT5Designer_LIBRARIES})
-
-qt5_wrap_cpp(vv_SRCS
-  vvMainWindowBase.h
-  QTreePushButton.h
-  vvDocumentation.h
-  vvHelpDialog.h
-  vvQDicomSeriesSelector.h
-  vvSlicerManager.h
-  vvSlicer.h
-  vvStructureSetActor.h
-  vvROIActor.h
-  vvToolCreatorBase.h
-  )
-
-qt5_wrap_ui(vv_UI_CXX
-  qt_ui/vvHelpDialog.ui
-  qt_ui/vvDocumentation.ui
-  qt_ui/vvDicomSeriesSelector.ui
-  qt_ui/vvDummyWindow.ui #For testing
-  )
-
-QT5_add_resources(vv_SRCS vvIcons.qrc)
-
-# Add the autotools in the header vvToolsList.h for initialization of the dummy
-# variables in vv.cxx for the tools contained in vvLib
-if(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
-  file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
-  foreach(tool ${vv_TOOLS})
-    file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "#include \"${tool}.h\"\n")
-    file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "extern const vvToolCreator<${tool}> *dummy${tool};\n")
-    file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "const vvToolCreator<${tool}> *dummy${tool}2 = dummy${tool};\n\n")
+  find_package(Qt5Widgets REQUIRED)
+  find_package(Qt5Network REQUIRED)
+  find_package(Qt5Designer REQUIRED)
+
+  link_directories(${QT5Widgets_LIBRARIES})
+  link_directories(${QT5Network_LIBRARIES})
+  link_directories(${QT5Designer_LIBRARIES})
+  qt5_wrap_cpp(vv_SRCS
+    vvMainWindowBase.h
+    QTreePushButton.h
+    vvDocumentation.h
+    vvHelpDialog.h
+    vvQDicomSeriesSelector.h
+    vvSlicerManager.h
+    vvSlicer.h
+    vvStructureSetActor.h
+    vvROIActor.h
+    vvToolCreatorBase.h
+    )
+  
+  qt5_wrap_ui(vv_UI_CXX
+    qt_ui/vvHelpDialog.ui
+    qt_ui/vvDocumentation.ui
+    qt_ui/vvDicomSeriesSelector.ui
+    qt_ui/vvDummyWindow.ui #For testing
+    )
+  
+  QT5_add_resources(vv_SRCS vvIcons.qrc)
+  
+  # Add the autotools in the header vvToolsList.h for initialization of the dummy
+  # variables in vv.cxx for the tools contained in vvLib
+  if(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
+    file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
+    foreach(tool ${vv_TOOLS})
+      file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "#include \"${tool}.h\"\n")
+      file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "extern const vvToolCreator<${tool}> *dummy${tool};\n")
+      file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "const vvToolCreator<${tool}> *dummy${tool}2 = dummy${tool};\n\n")
+    endforeach(tool)
+  endif(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
+  
+  # Add the autotools and the common files ui
+  foreach(tool ${vv_TOOLS} ${vv_COMMON_WITH_UI})
+      set(vv_SRCS ${vv_SRCS} ${tool}.cxx)
+      QT5_WRAP_CPP(vv_SRCS ${tool}.h)
+      QT5_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui)
   endforeach(tool)
-endif(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
-
-# Add the autotools and the common files ui
-foreach(tool ${vv_TOOLS} ${vv_COMMON_WITH_UI})
-    set(vv_SRCS ${vv_SRCS} ${tool}.cxx)
-    QT5_WRAP_CPP(vv_SRCS ${tool}.h)
-    QT5_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui)
-endforeach(tool)
-
-# Add the common source files
-foreach(tool ${vv_COMMON})
-    set(vv_SRCS ${vv_SRCS} ${tool}.cxx)
-    QT5_WRAP_CPP(vv_SRCS ${tool}.h)
-endforeach(tool)
-
-# if Windows and Qt was built as a static lib then don't set QT_DLL flag
-set(QT_STATIC 0)
-if(WIN32)
-  if(EXISTS ${Qt5Widgets_LIBRARIES}/QtCore.prl)
-    file(READ ${Qt5Widgets_LIBRARIES}/QtCore.prl QT_CORE_PRL)
-    if(${QT_CORE_PRL} MATCHES "static")
-      set(QT_STATIC 1)
-    endif(${QT_CORE_PRL} MATCHES "static")
-  endif(EXISTS ${Qt5Widgets_LIBRARIES}/QtCore.prl)
-endif(WIN32)
-if(NOT QT_STATIC)
-  add_definitions(-DQT_DLL)
-endif(NOT QT_STATIC)
-
-add_definitions(-DQT_THREAD_SUPPORT)
-
-include_directories(
-  ${Qt5Widgets_INCLUDE_DIRS}
-  ${Qt5GUI_INCLUDE_DIRS}
-  ${Qt5CORE_INCLUDE_DIRS}
-  ${Qt5Network_INCLUDE_DIRS}
-  ${Qt5Designer_INCLUDE_DIRS}
-  ${CMAKE_CURRENT_BINARY_DIR}
-  ${CMAKE_CURRENT_SOURCE_DIR}
-)
+  
+  # Add the common source files
+  foreach(tool ${vv_COMMON})
+      set(vv_SRCS ${vv_SRCS} ${tool}.cxx)
+      QT5_WRAP_CPP(vv_SRCS ${tool}.h)
+  endforeach(tool)
+  
+  # if Windows and Qt was built as a static lib then don't set QT_DLL flag
+  set(QT_STATIC 0)
+  if(WIN32)
+    if(EXISTS ${Qt5Widgets_LIBRARIES}/QtCore.prl)
+      file(READ ${Qt5Widgets_LIBRARIES}/QtCore.prl QT_CORE_PRL)
+      if(${QT_CORE_PRL} MATCHES "static")
+        set(QT_STATIC 1)
+      endif(${QT_CORE_PRL} MATCHES "static")
+    endif(EXISTS ${Qt5Widgets_LIBRARIES}/QtCore.prl)
+  endif(WIN32)
+  if(NOT QT_STATIC)
+    add_definitions(-DQT_DLL)
+  endif(NOT QT_STATIC)
+  add_definitions(-DQT_THREAD_SUPPORT)
+  include_directories(
+    ${Qt5Widgets_INCLUDE_DIRS}
+    ${Qt5Gui_INCLUDE_DIRS}
+    ${Qt5Core_INCLUDE_DIRS}
+    ${Qt5Network_INCLUDE_DIRS}
+    ${Qt5Designer_INCLUDE_DIRS}
+    ${CMAKE_CURRENT_BINARY_DIR}
+    ${CMAKE_CURRENT_SOURCE_DIR}
+    )
 else()
-find_package(Qt4 REQUIRED)
-link_directories(${QT_LIBRARY_DIR})
-
-
-QT4_WRAP_CPP(vv_SRCS
-  vvMainWindowBase.h
-  QTreePushButton.h
-  vvDocumentation.h
-  vvHelpDialog.h
-  vvQDicomSeriesSelector.h
-  vvSlicerManager.h
-  vvStructureSetActor.h
-  vvROIActor.h
-  vvToolCreatorBase.h
-  )
-
-QT4_WRAP_UI(vv_UI_CXX
-  qt_ui/vvHelpDialog.ui
-  qt_ui/vvDocumentation.ui
-  qt_ui/vvDicomSeriesSelector.ui
-  qt_ui/vvDummyWindow.ui #For testing
-  )
-
-QT4_ADD_RESOURCES(vv_SRCS vvIcons.qrc)
-
-# Add the autotools in the header vvToolsList.h for initialization of the dummy
-# variables in vv.cxx for the tools contained in vvLib
-if(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
-  file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
-  foreach(tool ${vv_TOOLS})
-    file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "#include \"${tool}.h\"\n")
-    file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "extern const vvToolCreator<${tool}> *dummy${tool};\n")
-    file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "const vvToolCreator<${tool}> *dummy${tool}2 = dummy${tool};\n\n")
+  find_package(Qt4 REQUIRED)
+  link_directories(${QT_LIBRARY_DIR})
+  
+  
+  QT4_WRAP_CPP(vv_SRCS
+    vvMainWindowBase.h
+    QTreePushButton.h
+    vvDocumentation.h
+    vvHelpDialog.h
+    vvQDicomSeriesSelector.h
+    vvSlicerManager.h
+    vvStructureSetActor.h
+    vvROIActor.h
+    vvToolCreatorBase.h
+    )
+  
+  QT4_WRAP_UI(vv_UI_CXX
+    qt_ui/vvHelpDialog.ui
+    qt_ui/vvDocumentation.ui
+    qt_ui/vvDicomSeriesSelector.ui
+    qt_ui/vvDummyWindow.ui #For testing
+    )
+  
+  QT4_ADD_RESOURCES(vv_SRCS vvIcons.qrc)
+  
+  # Add the autotools in the header vvToolsList.h for initialization of the dummy
+  # variables in vv.cxx for the tools contained in vvLib
+  if(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
+    file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
+    foreach(tool ${vv_TOOLS})
+      file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "#include \"${tool}.h\"\n")
+      file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "extern const vvToolCreator<${tool}> *dummy${tool};\n")
+      file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "const vvToolCreator<${tool}> *dummy${tool}2 = dummy${tool};\n\n")
+    endforeach(tool)
+  endif(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
+  
+  # Add the autotools and the common files ui
+  foreach(tool ${vv_TOOLS} ${vv_COMMON_WITH_UI})
+      set(vv_SRCS ${vv_SRCS} ${tool}.cxx)
+      QT4_WRAP_CPP(vv_SRCS ${tool}.h)
+      QT4_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui)
   endforeach(tool)
-endif(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
-
-# Add the autotools and the common files ui
-foreach(tool ${vv_TOOLS} ${vv_COMMON_WITH_UI})
-    set(vv_SRCS ${vv_SRCS} ${tool}.cxx)
-    QT4_WRAP_CPP(vv_SRCS ${tool}.h)
-    QT4_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui)
-endforeach(tool)
-
-# Add the common source files
-foreach(tool ${vv_COMMON})
-    set(vv_SRCS ${vv_SRCS} ${tool}.cxx)
-    QT4_WRAP_CPP(vv_SRCS ${tool}.h)
-endforeach(tool)
-
-# if Windows and Qt was built as a static lib then don't set QT_DLL flag
-set(QT_STATIC 0)
-if(WIN32)
-  if(EXISTS ${QT_LIBRARY_DIR}/QtCore.prl)
-    file(READ ${QT_LIBRARY_DIR}/QtCore.prl QT_CORE_PRL)
-    if(${QT_CORE_PRL} MATCHES "static")
-      set(QT_STATIC 1)
-    endif(${QT_CORE_PRL} MATCHES "static")
-  endif(EXISTS ${QT_LIBRARY_DIR}/QtCore.prl)
-endif(WIN32)
-if(NOT QT_STATIC)
-  add_definitions(-DQT_DLL)
-endif(NOT QT_STATIC)
-
-add_definitions(-DQT_THREAD_SUPPORT)
-
-include_directories(
-  ${QT_INCLUDES}
-  ${QT_INCLUDE_DIR}
-  ${QT_QTGUI_INCLUDE_DIR}
-  ${QT_QTCORE_INCLUDE_DIR}
-  ${CMAKE_CURRENT_BINARY_DIR}
-  ${CMAKE_CURRENT_SOURCE_DIR}
-)
+  
+  # Add the common source files
+  foreach(tool ${vv_COMMON})
+      set(vv_SRCS ${vv_SRCS} ${tool}.cxx)
+      QT4_WRAP_CPP(vv_SRCS ${tool}.h)
+  endforeach(tool)
+  
+  # if Windows and Qt was built as a static lib then don't set QT_DLL flag
+  set(QT_STATIC 0)
+  if(WIN32)
+    if(EXISTS ${QT_LIBRARY_DIR}/QtCore.prl)
+      file(READ ${QT_LIBRARY_DIR}/QtCore.prl QT_CORE_PRL)
+      if(${QT_CORE_PRL} MATCHES "static")
+        set(QT_STATIC 1)
+      endif(${QT_CORE_PRL} MATCHES "static")
+    endif(EXISTS ${QT_LIBRARY_DIR}/QtCore.prl)
+  endif(WIN32)
+  if(NOT QT_STATIC)
+    add_definitions(-DQT_DLL)
+  endif(NOT QT_STATIC)
+  
+  add_definitions(-DQT_THREAD_SUPPORT)
+  
+  include_directories(
+    ${QT_INCLUDES}
+    ${QT_INCLUDE_DIR}
+    ${QT_QTGUI_INCLUDE_DIR}
+    ${QT_QTCORE_INCLUDE_DIR}
+    ${CMAKE_CURRENT_BINARY_DIR}
+    ${CMAKE_CURRENT_SOURCE_DIR}
+  )
 endif()
 #=========================================================
 
@@ -332,6 +331,13 @@ set(vvExternalLibs clitkSegmentationGgoLib ${toolLibs} ${foundationLibraries} ${
 endif()
 # QtNetwork is required by vvRegisterForm
 
+#-----------------------------------------------------------------------------
+# For retina displays, see
+# http://public.kitware.com/pipermail/vtkusers/2015-February/090117.html
+if(APPLE)
+  set(vv_SRCS ${vv_SRCS} vvOSXHelper.mm)
+endif()
+
 add_library(vvLib ${vv_SRCS} ${vv_UI_CXX})
 target_link_libraries(vvLib ${vvExternalLibs})
 
index be61470145281553829a7a07d941f71727125983..45f848a5e19144af25b08af1311ab3caaac9ddc4 100644 (file)
@@ -50,6 +50,9 @@ It is distributed under dual licence
 #include "vvReadState.h"
 #include "clitkConfiguration.h"
 #include "clitkMatrix.h"
+#ifdef Q_OS_OSX
+# include "vvOSXHelper.h"
+#endif
 
 // ITK include
 #include <itkImage.h>
@@ -201,21 +204,6 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
     tr("Reset transformation to identity"));
   connect(actionResetMatrix, SIGNAL(triggered()), this,SLOT(ResetTransformationToIdentity()));
 
-  // TRIAL DS
-  /*
-  QMenu * m = new QMenu(menubar);
-  m->setTitle("TOTO");
-  //  m->setObjectName(QString::fromUtf8("TOTOTO"));
-  contextMenu.addMenu(m);
-  QAction * a = m->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")),
-  tr("BIDON"));
-  QAction * b = m->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")),
-  tr("BIDON2"));
-  m->addAction(a);
-  m->addAction(b);
-  connect(a,SIGNAL(triggered()),this,SLOT(AddFusionImage()));
-  */
-
   //init the DataTree
   mSlicerManagers.resize(0);
 
@@ -372,6 +360,13 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
   SOViewWidget->hide();
   SEViewWidget->hide();
 
+#ifdef Q_OS_OSX
+  disableGLHiDPI(NOViewWidget->winId());
+  disableGLHiDPI(NEViewWidget->winId());
+  disableGLHiDPI(SOViewWidget->winId());
+  disableGLHiDPI(SEViewWidget->winId());
+#endif
+
   //Recently opened files
   std::list<std::string> recent_files = GetRecentlyOpenedImages();
   recentlyOpenedFilesMenu=NULL;
@@ -392,8 +387,8 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
   //timerMemory->setInterval(5);
   connect(timerMemory, SIGNAL(timeout()), this, SLOT(UpdateMemoryUsage()));
   timerMemory->start(2000);
-
 }
+
 //------------------------------------------------------------------------------
 void vvMainWindow::show()
 { 
diff --git a/vv/vvOSXHelper.h b/vv/vvOSXHelper.h
new file mode 100644 (file)
index 0000000..2d9f296
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef _OSX_HELPER_
+#define _OSX_HELPER_
+
+// For retina displays, see
+// http://public.kitware.com/pipermail/vtkusers/2015-February/090117.html
+void disableGLHiDPI( long a_id );
+
+#endif
+
diff --git a/vv/vvOSXHelper.mm b/vv/vvOSXHelper.mm
new file mode 100644 (file)
index 0000000..20898a2
--- /dev/null
@@ -0,0 +1,10 @@
+#include <Cocoa/Cocoa.h>
+#include "vvOSXHelper.h"
+
+// For retina displays, see
+// http://public.kitware.com/pipermail/vtkusers/2015-February/090117.html
+void disableGLHiDPI( long a_id ){
+ NSView *view = reinterpret_cast<NSView*>( a_id );
+ [view setWantsBestResolutionOpenGLSurface:NO];
+}
+