avogadro2-0.8.0-vtk.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. commit 23a9474aad8eba503bcfe54584fd7cad106bda17
  2. Author: Marcus D. Hanwell <marcus.hanwell@kitware.com>
  3. Date: Mon Sep 21 12:03:07 2015 -0400
  4. Made VTK truly optional for Avogadro application
  5. diff --git a/avogadro/CMakeLists.txt b/avogadro/CMakeLists.txt
  6. index 90534ea..24bdd46 100644
  7. --- a/avogadro/CMakeLists.txt
  8. +++ b/avogadro/CMakeLists.txt
  9. @@ -8,6 +8,7 @@ option(USE_VTK "Build with VTK support" OFF)
  10. if(USE_VTK)
  11. find_package(VTK COMPONENTS vtkGUISupportQt vtkRenderingOpenGL REQUIRED)
  12. include(${VTK_USE_FILE})
  13. + add_definitions(-DAVO_USE_VTK)
  14. endif()
  15. if(MSVC)
  16. diff --git a/avogadro/mainwindow.cpp b/avogadro/mainwindow.cpp
  17. index a1c09e8..8fe3038 100644
  18. --- a/avogadro/mainwindow.cpp
  19. +++ b/avogadro/mainwindow.cpp
  20. @@ -81,7 +81,9 @@
  21. # include <molequeue/client/client.h>
  22. #endif // Avogadro_ENABLE_RPC
  23. -#include <avogadro/vtk/vtkglwidget.h>
  24. +#ifdef AVO_USE_VTK
  25. +# include <avogadro/vtk/vtkglwidget.h>
  26. +#endif
  27. namespace Avogadro {
  28. @@ -198,8 +200,10 @@ using QtGui::ToolPluginFactory;
  29. using QtGui::ExtensionPlugin;
  30. using QtGui::ExtensionPluginFactory;
  31. using QtOpenGL::GLWidget;
  32. -using VTK::vtkGLWidget;
  33. using QtPlugins::PluginManager;
  34. +#ifdef AVO_USE_VTK
  35. +using VTK::vtkGLWidget;
  36. +#endif
  37. MainWindow::MainWindow(const QStringList &fileNames, bool disableSettings)
  38. : m_molecule(NULL),
  39. @@ -434,9 +438,11 @@ void MainWindow::setMolecule(Molecule *mol)
  40. if (GLWidget *glWidget = qobject_cast<QtOpenGL::GLWidget *>(w)) {
  41. setWidgetMolecule(glWidget, mol);
  42. }
  43. +#ifdef AVO_USE_VTK
  44. else if (vtkGLWidget *vtkWidget = qobject_cast<vtkGLWidget *>(w)) {
  45. setWidgetMolecule(vtkWidget, mol);
  46. }
  47. +#endif
  48. }
  49. void MainWindow::markMoleculeDirty()
  50. @@ -831,6 +837,7 @@ void MainWindow::viewActivated(QWidget *widget)
  51. m_moleculeModel->setActiveMolecule(m_molecule);
  52. }
  53. }
  54. +#ifdef AVO_USE_VTK
  55. else if (vtkGLWidget *vtkWidget = qobject_cast<vtkGLWidget*>(widget)) {
  56. bool firstRun = populatePluginModel(vtkWidget->sceneModel());
  57. m_sceneTreeView->setModel(&vtkWidget->sceneModel());
  58. @@ -851,6 +858,7 @@ void MainWindow::viewActivated(QWidget *widget)
  59. m_moleculeModel->setActiveMolecule(m_molecule);
  60. }
  61. }
  62. +#endif
  63. updateWindowTitle();
  64. activeMoleculeEdited();
  65. }
  66. @@ -1194,14 +1202,18 @@ void MainWindow::setActiveDisplayTypes(QStringList displayTypes)
  67. {
  68. ScenePluginModel *scenePluginModel(NULL);
  69. GLWidget *glWidget(NULL);
  70. +#ifdef AVO_USE_VTK
  71. VTK::vtkGLWidget *vtkWidget(NULL);
  72. +#endif
  73. if ((glWidget = qobject_cast<GLWidget *>(m_multiViewWidget->activeWidget()))) {
  74. scenePluginModel = &glWidget->sceneModel();
  75. }
  76. +#ifdef AVO_USE_VTK
  77. else if ((vtkWidget =
  78. qobject_cast<VTK::vtkGLWidget *>(m_multiViewWidget->activeWidget()))) {
  79. scenePluginModel = &vtkWidget->sceneModel();
  80. }
  81. +#endif
  82. foreach (ScenePlugin *scene, scenePluginModel->scenePlugins())
  83. scene->setEnabled(false);
  84. @@ -1211,8 +1223,10 @@ void MainWindow::setActiveDisplayTypes(QStringList displayTypes)
  85. scene->setEnabled(true);
  86. if (glWidget)
  87. glWidget->updateScene();
  88. +#ifdef AVO_USE_VTK
  89. else if (vtkWidget)
  90. vtkWidget->updateScene();
  91. +#endif
  92. }
  93. void MainWindow::undoEdit()
  94. diff --git a/avogadro/viewfactory.cpp b/avogadro/viewfactory.cpp
  95. index 28009be..15c6a44 100644
  96. --- a/avogadro/viewfactory.cpp
  97. +++ b/avogadro/viewfactory.cpp
  98. @@ -17,7 +17,9 @@
  99. #include "viewfactory.h"
  100. #include <avogadro/qtopengl/glwidget.h>
  101. -#include <avogadro/vtk/vtkglwidget.h>
  102. +#ifdef AVO_USE_VTK
  103. +# include <avogadro/vtk/vtkglwidget.h>
  104. +#endif
  105. namespace Avogadro {
  106. @@ -31,15 +33,22 @@ ViewFactory::~ViewFactory()
  107. QStringList ViewFactory::views() const
  108. {
  109. - return QStringList() << "3D View" << "VTK";
  110. + QStringList views;
  111. + views << "3D View";
  112. +#ifdef AVO_USE_VTK
  113. + views << "VTK";
  114. +#endif
  115. + return views;
  116. }
  117. QWidget * ViewFactory::createView(const QString &view)
  118. {
  119. if (view == "3D View")
  120. return new QtOpenGL::GLWidget;
  121. +#ifdef AVO_USE_VTK
  122. else if (view == "VTK")
  123. return new VTK::vtkGLWidget;
  124. +#endif
  125. return NULL;
  126. }