Commit c6bbda1c authored by Tim Giroux's avatar Tim Giroux Committed by Jesse Mapel
Browse files

Csmbundle - remove SIP wrappers and deprecated formatBundleOutputString (#4526)

* remove sip wrappers

* remove deprecated formatBundleOutputString

* remove more sip code and formatBundleOutputString
parent 31225b73
Loading
Loading
Loading
Loading
+0 −65
Original line number Diff line number Diff line
@@ -303,7 +303,6 @@ endif(APPLE)

if(pybindings)
 find_package(Python REQUIRED)
 find_package(Sip    REQUIRED)
endif()

# Iterate through all variables and extract the libraries and include directories
@@ -356,70 +355,6 @@ list(REMOVE_DUPLICATES ALLLIBDIRS)
list(REMOVE_DUPLICATES ALLLIBS)
list(REMOVE_DUPLICATES ALLINCDIRS)

#===============================================================================
#===============================================================================

# Set python bindings configuration and set target for generating C++ files
if(pybindings)
  message("Configuring Python Bindings")

  if (NOT DEFINED PYINSTALL_DIR)
    set(PYINSTALL_DIR ${PYTHON_SITE_PACKAGES_DIR})
  endif()
  message(STATUS "PYTHON BINDINGS INSTALL DIR: ${PYINSTALL_DIR}")

 # We need to get the locations for sip files, modules, etc.
 set(ISIS_SIP_DIR "${CMAKE_SOURCE_DIR}/sipfiles")
 set(ISIS_SIP_MODULE "${CMAKE_SOURCE_DIR}/sipfiles/master.sip")
 set(SIP_BUILD_FILE "isispy.sbf")
 set(ISIS_SIP_CODE_DIR ${CMAKE_BINARY_DIR}/sipsrc)

 # Create the output directory for the new .CPP files
 execute_process(COMMAND mkdir -p "${ISIS_SIP_CODE_DIR}")

 # get list of output files exepected from sip

 # get the PYQT configuration based flags from Python
 execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
                 "from PyQt5.QtCore import PYQT_CONFIGURATION as qtconfigdict;print(qtconfigdict['sip_flags'])"
                 OUTPUT_VARIABLE PYQT_SIP_FLAGS)

 # CMAKE doesn't handle spaces from python well when piping that into the
 # command because of white space and a trailing new line,
 # so we turn it into a list
 message(STATUS "Getting SIP config...")
 message(STATUS "Attempting 'python -c \"from PyQt5.QtCore import PYQT_CONFIGURATION as qtconfigdict; print(qtconfigdict['sip_flags'])\"'")

 if (${PYQT_SIP_FLAGS} STREQUAL "")
    message(FATAL_ERROR "print(qtconfigdict['sip_flags']) returned empty string, is sip installed? Python binding can be disabled with pybindings=OFF")
 endif()
 string(STRIP ${PYQT_SIP_FLAGS} PYQT_SIP_FLAGS)
 string(REPLACE " " ";" PYQT_SIP_FLAGS ${PYQT_SIP_FLAGS})

 message(STATUS "FLAGS: ${PYQT_SIP_FLAGS}")
 message(STATUS "Generating C++ code from sip files")
 message(STATUS "SIP BUILD FILE: ${SIP_BUILD_FILE}")
 message(STATUS "SIP MODULE: ${ISIS_SIP_MODULE}")
 message(STATUS "SIP GENERATED CODE DIR: ${ISIS_SIP_CODE_DIR}")

 execute_process(COMMAND ${SIP_BINARY_PATH} -e -o -c ${ISIS_SIP_CODE_DIR} -I ${SIP_DEFAULT_SIP_DIR}/PyQt5 ${PYQT_SIP_FLAGS} ${ISIS_SIP_MODULE})

 # add target so users can run the command after initial configuration
 add_custom_target(sipfiles
                  COMMAND ${SIP_BINARY_PATH} -e -o -c ${ISIS_SIP_CODE_DIR} -I ${SIP_DEFAULT_SIP_DIR}/PyQt5 ${PYQT_SIP_FLAGS} ${ISIS_SIP_MODULE}
                  COMMENT "Generating C++ code from sip files")

 file(GLOB SIP_GENERATED_SOURCE_FILES ${ISIS_SIP_CODE_DIR}/*.cpp)
 add_library(isispy MODULE ${SIP_GENERATED_SOURCE_FILES})
 target_link_libraries(isispy ${ALLLIBS})
 target_link_libraries(isispy isis)
 set_target_properties(isispy PROPERTIES LINK_DEPENDS isis INSTALL_RPATH ${CMAKE_INSTALL_PREFIX})
 add_dependencies(isispy sipfiles)

 install(TARGETS isispy DESTINATION ${PYINSTALL_DIR})
endif()


#===============================================================================
#===============================================================================

isis/cmake/FindSip.cmake

deleted100644 → 0
+0 −44
Original line number Diff line number Diff line
# Borrowed mostly from the QGIS project: https://github.com/qgis/QGIS
#
# SIP_VERSION - The version of SIP found expressed as a 6 digit hex number
#     suitable for comparison as a string.
#
# SIP_VERSION_STR - The version of SIP found as a human readable string.
#
# SIP_BINARY_PATH - Path and filename of the SIP command line executable.
#
# SIP_INCLUDE_DIR - Directory holding the SIP C++ header file.
#
# SIP_DEFAULT_SIP_DIR - Default directory where .sip files should be installed
#     into.

IF(SIP_VERSION)
  # Already in cache, be silent
  SET(SIP_FOUND TRUE)
ELSE(SIP_VERSION)

  FIND_FILE(_find_sip_py FindSip.py PATHS ${CMAKE_MODULE_PATH})

  EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_sip_py} OUTPUT_VARIABLE sip_config)
  IF(sip_config)
    STRING(REGEX REPLACE "^sip_version:([^\n]+).*$" "\\1" SIP_VERSION ${sip_config})
    STRING(REGEX REPLACE ".*\nsip_version_num:([^\n]+).*$" "\\1" SIP_VERSION_NUM ${sip_config})
    STRING(REGEX REPLACE ".*\nsip_version_str:([^\n]+).*$" "\\1" SIP_VERSION_STR ${sip_config})
    STRING(REGEX REPLACE ".*\nsip_bin:([^\n]+).*$" "\\1" SIP_BINARY_PATH ${sip_config})
    STRING(REGEX REPLACE ".*\ndefault_sip_dir:([^\n]+).*$" "\\1" SIP_DEFAULT_SIP_DIR ${sip_config})
    STRING(REGEX REPLACE ".*\nsip_inc_dir:([^\n]+).*$" "\\1" SIP_INCLUDE_DIR ${sip_config})
    STRING(REGEX REPLACE ".*\nsip_mod_dir:([^\n]+).*$" "\\1" SIP_MOD_DIR ${sip_config})
    SET(SIP_FOUND TRUE)
  ENDIF(sip_config)

  IF(SIP_FOUND)
    IF(NOT SIP_FIND_QUIETLY)
      MESSAGE(STATUS "Found SIP version: ${SIP_VERSION_STR}")
    ENDIF(NOT SIP_FIND_QUIETLY)
  ELSE(SIP_FOUND)
    IF(SIP_FIND_REQUIRED)
      MESSAGE(FATAL_ERROR "Could not find SIP")
    ENDIF(SIP_FIND_REQUIRED)
  ENDIF(SIP_FOUND)

ENDIF(SIP_VERSION)

isis/cmake/FindSip.py

deleted100644 → 0
+0 −13
Original line number Diff line number Diff line
# Borrowed mostly from the QGIS project: https://github.com/qgis/QGIS


import sipconfig

sipcfg = sipconfig.Configuration()
print("sip_version:%06.0x" % sipcfg.sip_version)
print("sip_version_num:%d" % sipcfg.sip_version)
print("sip_version_str:%s" % sipcfg.sip_version_str)
print("sip_bin:%s" % sipcfg.sip_bin)
print("default_sip_dir:%s" % sipcfg.default_sip_dir)
print("sip_inc_dir:%s" % sipcfg.sip_inc_dir)
print("sip_mod_dir:%s" % sipcfg.sip_mod_dir)

isis/sipfiles/BundleAdjust.sip

deleted100644 → 0
+0 −42
Original line number Diff line number Diff line
// SIP Wrapper to the ISIS bundle class
%Include type_conversions.sip


namespace Isis {
  class BundleAdjust : public QObject {
    %TypeHeaderCode
    #include "BundleAdjust.h"
    #include "IException.h"
    %End

  public:
    // Stuff in the square brackets [] indicate the C++ interface while the sip
    // function name indicates the C python function interface
    BundleAdjust(PyObject* settings, const QString &cnetFile, const QString &cubeList, bool printSummary = true) throw(Isis::IException) [(QSharedPointer<Isis::BundleSettings>, QString, QString, bool)];
    %MethodCode
      int sipErr = 0;
      QSharedPointer<Isis::BundleSettings> *wrappedSettings = new QSharedPointer<Isis::BundleSettings>();

      Isis::BundleSettings *settings = (Isis::BundleSettings*) sipConvertToType(a0, sipType_Isis_BundleSettings, NULL, SIP_NOT_NONE, NULL, &sipErr);
      wrappedSettings->reset(settings);
      try {
        sipCpp = new sipIsis_BundleAdjust(*wrappedSettings, *a1, *a2, a3);
      }
      catch (Isis::IException &error) {
          PyErr_SetString(sipException_Isis_IException, error.what());
          return NULL;
      }
    %End

    Isis::BundleSolutionInfo* solveCholeskyBR();
    %MethodCode
      try {
        return sipConvertFromType(sipCpp->solveCholeskyBR(), sipType_Isis_BundleSolutionInfo, NULL);
      }
      catch (Isis::IException &error) {
          PyErr_SetString(sipException_Isis_IException, error.what());
          return NULL;
      }
    %End
   };
};
+0 −68
Original line number Diff line number Diff line
namespace Isis {
  class BundleControlPoint {

    %TypeHeaderCode
    #include "BundleControlPoint.h"
    #include <QSharedPointer>
    %End

    public:

      SIP_PYTYPE measures() throw(Isis::IException);
      %MethodCode
        size_t size = sipCpp->size();

        PyObject *l = PyList_New(size);
        for (size_t i = 0; i < size; ++i) {
          Isis::BundleMeasure* cppMeasure = sipCpp->at(i).data();

          PyObject *pyMeasure = sipConvertFromType((void*)(cppMeasure), sipType_Isis_BundleMeasure, NULL);
          PyList_SetItem(l, i, pyMeasure);
        }

        return l;

      %End

      // BundleControlPoint(ControlPoint *point); // default constructor
      BundleControlPoint(const Isis::BundleControlPoint &src) throw(Isis::IException);
      ~BundleControlPoint();

      // copy
      void copy(const Isis::BundleControlPoint &src) throw(Isis::IException);

      // mutators
      // QSharedPointer<Isis::BundleMeasure> addMeasure(ControlMeasure *controlMeasure);
      void computeResiduals() throw(Isis::IException);
      void setNumberOfRejectedMeasures(int numRejected) throw(Isis::IException);
      void setRejected(bool reject) throw(Isis::IException);
      void setWeights(const QSharedPointer<Isis::BundleSettings> settings, double metersToRadians) throw(Isis::IException);
      void zeroNumberOfRejectedMeasures() throw(Isis::IException);

      // accessors
      bool isRejected() const throw(Isis::IException);
      int numberOfMeasures() const throw(Isis::IException);
      int numberOfRejectedMeasures() const throw(Isis::IException);
      double residualRms() const throw(Isis::IException);
      QString id() const throw(Isis::IException);
      Isis::ControlPoint::PointType type() const throw(Isis::IException);

      // string format methods
      QString formatBundleOutputSummaryString(bool errorPropagation) const throw(Isis::IException);
      QString formatBundleOutputDetailString(bool errorPropagation, double RTM, bool solveRadius=false) throw(Isis::IException) /KeywordArgs="Optional"/;
      QString formatValue(double value, int fieldWidth, int precision) throw(Isis::IException);
      QString formatAprioriSigmaString(int type, int fieldWidth, int precision, bool solveRadius=false) throw(Isis::IException) /KeywordArgs="Optional"/;
      QString formatLatitudeAprioriSigmaString(int fieldWidth, int precision) const throw(Isis::IException);
      QString formatLongitudeAprioriSigmaString(int fieldWidth, int precision) const throw(Isis::IException);
      QString formatRadiusAprioriSigmaString(int fieldWidth, int precision, bool solveRadius=false) throw(Isis::IException) /KeywordArgs="Optional"/;
      QString formatAdjustedSigmaString(int type, int fieldWidth, int precision,
                                        bool errorPropagation) const throw(Isis::IException);
      QString formatLatitudeAdjustedSigmaString(int fieldWidth, int precision,
                                                bool errorPropagation) const throw(Isis::IException);
      QString formatLongitudeAdjustedSigmaString(int fieldWidth, int precision,
                                                 bool errorPropagation) const throw(Isis::IException);
      QString formatRadiusAdjustedSigmaString(int fieldWidth, int precision,
                                              bool errorPropagation) const throw(Isis::IException);

  };
};
Loading