瀏覽代碼

Merge branch 'log4qt'

Daniel Blezek 15 年之前
父節點
當前提交
54458ce0b6

+ 20 - 0
CMakeExternals/log4qt.cmake

@@ -0,0 +1,20 @@
+#
+# log4qt
+#
+SET(log4qt_DEPENDS)
+ctkMacroShouldAddExternalProject(log4qt_LIBRARIES add_project)
+IF(${add_project})
+  IF(NOT DEFINED log4qt_DIR)
+    SET(proj log4qt)
+#     MESSAGE(STATUS "Adding project:${proj}")
+    SET(log4qt_DEPENDS ${proj})
+    ExternalProject_Add(${proj}
+        DOWNLOAD_COMMAND ""
+        CMAKE_GENERATOR ${gen}
+        SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/${proj}
+        CMAKE_ARGS
+          ${ep_common_args}
+        )
+    SET(log4qt_DIR ${ep_install_dir})
+  ENDIF()
+ENDIF()

+ 4 - 4
Libs/Core/CMakeLists.txt

@@ -6,9 +6,9 @@ SET(CMAKE_MODULE_PATH ${CTKCore_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH})
 # CMake Macros
 INCLUDE(CMake/ctkMacroBFDCheck.cmake)
 
-FIND_PACKAGE(log4cpp)
-if ( NOT log4cpp_FOUND )
-  MESSAGE(FATAL_ERROR "error: log4cpp package is required to build ${PROJECT_NAME}" )
+FIND_PACKAGE(log4qt)
+if ( NOT log4qt_FOUND )
+  MESSAGE(FATAL_ERROR "error: log4qt package is required to build ${PROJECT_NAME}" )
 endif()
 #
 # See CTK/CMake/ctkMacroBuildLib.cmake for details
@@ -18,7 +18,7 @@ SET(KIT_export_directive "CTK_CORE_EXPORT")
 
 # Additional directories to include
 SET(KIT_include_directories
-  ${log4cpp_INCLUDE_DIR}
+  ${log4qt_INCLUDE_DIR}
   )
   
 # Source files

+ 49 - 112
Libs/Core/ctkLogger.cpp

@@ -25,181 +25,118 @@
 #include "ctkLogger.h"
 
 // log4cpp
-#include <log4cpp/BasicConfigurator.hh>
-#include <log4cpp/PropertyConfigurator.hh>
-#include <log4cpp/Layout.hh>
-#include <log4cpp/Priority.hh>
-#include <log4cpp/Category.hh>
-#include <log4cpp/PatternLayout.hh>
-#include <log4cpp/BasicLayout.hh>
-#include <log4cpp/OstreamAppender.hh>
-#include <log4cpp/FileAppender.hh>
+#include "log4qt/log4qt.h"
+#include "log4qt/logger.h"
 
-
-class ctkLogger::ctkInternal {
+class ctkLoggerPrivate: public ctkPrivate<ctkLogger>
+{
 public:
-  ctkInternal( QString name ) : Logger ( ::log4cpp::Category::getInstance ( name.toStdString().c_str() ) ) {
-  }
-  log4cpp::Category& Logger;
+  ctkLoggerPrivate() {};
+  ~ctkLoggerPrivate() {};
+  Log4Qt::Logger *Logger;
 };
 
 ctkLogger::ctkLogger(QString name, QObject* _parent): Superclass(_parent)
 {
-  this->Internal = new ctkInternal ( name );
+  CTK_D(ctkLogger);
+  d->Logger = Log4Qt::Logger::logger( name.toStdString().c_str() );
 }
 
 ctkLogger::~ctkLogger()
 {
-  delete this->Internal;
 }
 
-
-
 void ctkLogger::debug ( QString s ) 
 { 
-  this->Internal->Logger.debug ( s.toStdString() );
+  CTK_D(ctkLogger);
+  d->Logger->debug ( s );
 }
 void ctkLogger::info ( QString s ) 
 { 
-  this->Internal->Logger.info ( s.toStdString() );
+  CTK_D(ctkLogger);
+  d->Logger->info ( s );
 }
-void ctkLogger::notice ( QString s ) 
+void ctkLogger::trace ( QString s ) 
 { 
-  this->Internal->Logger.notice ( s.toStdString() );
+  CTK_D(ctkLogger);
+  d->Logger->trace ( s );
 }
 void ctkLogger::warn ( QString s ) 
 { 
-  this->Internal->Logger.warn ( s.toStdString() );
-}
-void ctkLogger::warning ( QString s ) 
-{ 
-  this->Internal->Logger.warn ( s.toStdString() );
+  CTK_D(ctkLogger);
+  d->Logger->warn ( s );
 }
 void ctkLogger::error ( QString s ) 
 { 
-  this->Internal->Logger.error ( s.toStdString() );
-}
-void ctkLogger::crit ( QString s ) 
-{ 
-  this->Internal->Logger.crit ( s.toStdString() );
-}
-void ctkLogger::critical ( QString s ) 
-{ 
-  this->Internal->Logger.crit ( s.toStdString() );
-}
-void ctkLogger::alert ( QString s ) 
-{ 
-  this->Internal->Logger.alert ( s.toStdString() );
-}
-void ctkLogger::emerg ( QString s ) 
-{ 
-  this->Internal->Logger.emerg ( s.toStdString() );
-}
-void ctkLogger::emergercy ( QString s ) 
-{ 
-  this->Internal->Logger.emerg ( s.toStdString() );
+  CTK_D(ctkLogger);
+  d->Logger->error ( s );
 }
 void ctkLogger::fatal ( QString s ) 
 { 
-  this->Internal->Logger.fatal ( s.toStdString() );
+  CTK_D(ctkLogger);
+  d->Logger->fatal ( s );
 }
 
 void ctkLogger::setDebug() 
-{ 
-  this->Internal->Logger.setPriority ( log4cpp::Priority::DEBUG ); 
+{
+  CTK_D(ctkLogger);
+  d->Logger->setLevel ( Log4Qt::Level ( Log4Qt::Level::DEBUG_INT ) ); 
 }
 void ctkLogger::setInfo() 
 { 
-  this->Internal->Logger.setPriority ( log4cpp::Priority::INFO ); 
+  CTK_D(ctkLogger);
+  d->Logger->setLevel ( Log4Qt::Level ( Log4Qt::Level::INFO_INT ) ); 
 }
-void ctkLogger::setNotice() 
+void ctkLogger::setTrace() 
 { 
-  this->Internal->Logger.setPriority ( log4cpp::Priority::NOTICE ); 
+  CTK_D(ctkLogger);
+  d->Logger->setLevel ( Log4Qt::Level ( Log4Qt::Level::TRACE_INT ) ); 
 }
 void ctkLogger::setWarn() 
 { 
-  this->Internal->Logger.setPriority ( log4cpp::Priority::WARN ); 
-}
-void ctkLogger::setWarning() 
-{ 
-  this->Internal->Logger.setPriority ( log4cpp::Priority::WARN ); 
+  CTK_D(ctkLogger);
+  d->Logger->setLevel ( Log4Qt::Level ( Log4Qt::Level::WARN_INT ) ); 
 }
 void ctkLogger::setError() 
 { 
-  this->Internal->Logger.setPriority ( log4cpp::Priority::ERROR ); 
-}
-void ctkLogger::setCrit() 
-{ 
-  this->Internal->Logger.setPriority ( log4cpp::Priority::CRIT ); 
-}
-void ctkLogger::setCritical() 
-{ 
-  this->Internal->Logger.setPriority ( log4cpp::Priority::CRIT ); 
-}
-void ctkLogger::setAlert() 
-{ 
-  this->Internal->Logger.setPriority ( log4cpp::Priority::ALERT ); 
-}
-void ctkLogger::setEmerg() 
-{ 
-  this->Internal->Logger.setPriority ( log4cpp::Priority::EMERG ); 
-}
-void ctkLogger::setEmergercy() 
-{ 
-  this->Internal->Logger.setPriority ( log4cpp::Priority::EMERG ); 
+  CTK_D(ctkLogger);
+  d->Logger->setLevel ( Log4Qt::Level ( Log4Qt::Level::ERROR_INT ) ); 
 }
 void ctkLogger::setFatal() 
 { 
-  this->Internal->Logger.setPriority ( log4cpp::Priority::FATAL ); 
+  CTK_D(ctkLogger);
+  d->Logger->setLevel ( Log4Qt::Level ( Log4Qt::Level::FATAL_INT ) ); 
 }
 
 bool ctkLogger::isDebugEnabled() 
 { 
-  return this->Internal->Logger.isPriorityEnabled ( log4cpp::Priority::DEBUG ); 
+  CTK_D(ctkLogger);
+  return d->Logger->isDebugEnabled(); 
 }
 bool ctkLogger::isInfoEnabled() 
 { 
-  return this->Internal->Logger.isPriorityEnabled ( log4cpp::Priority::INFO ); 
+  CTK_D(ctkLogger);
+  return d->Logger->isInfoEnabled(); 
 }
-bool ctkLogger::isNoticeEnabled() 
+bool ctkLogger::isTraceEnabled() 
 { 
-  return this->Internal->Logger.isPriorityEnabled ( log4cpp::Priority::NOTICE ); 
+  CTK_D(ctkLogger);
+  return d->Logger->isTraceEnabled(); 
 }
 bool ctkLogger::isWarnEnabled() 
 { 
-  return this->Internal->Logger.isPriorityEnabled ( log4cpp::Priority::WARN ); 
-}
-bool ctkLogger::isWarningEnabled() 
-{ 
-  return this->Internal->Logger.isPriorityEnabled ( log4cpp::Priority::WARN ); 
+  CTK_D(ctkLogger);
+  return d->Logger->isWarnEnabled(); 
 }
 bool ctkLogger::isErrorEnabled() 
 { 
-  return this->Internal->Logger.isPriorityEnabled ( log4cpp::Priority::ERROR ); 
-}
-bool ctkLogger::isCritEnabled() 
-{ 
-  return this->Internal->Logger.isPriorityEnabled ( log4cpp::Priority::CRIT ); 
-}
-bool ctkLogger::isCriticalEnabled() 
-{ 
-  return this->Internal->Logger.isPriorityEnabled ( log4cpp::Priority::CRIT ); 
-}
-bool ctkLogger::isAlertEnabled() 
-{ 
-  return this->Internal->Logger.isPriorityEnabled ( log4cpp::Priority::ALERT ); 
-}
-bool ctkLogger::isEmergEnabled() 
-{ 
-  return this->Internal->Logger.isPriorityEnabled ( log4cpp::Priority::EMERG ); 
-}
-bool ctkLogger::isEmergercyEnabled() 
-{ 
-  return this->Internal->Logger.isPriorityEnabled ( log4cpp::Priority::EMERG ); 
+  CTK_D(ctkLogger);
+  return d->Logger->isErrorEnabled(); 
 }
 bool ctkLogger::isFatalEnabled() 
 { 
-  return this->Internal->Logger.isPriorityEnabled ( log4cpp::Priority::FATAL ); 
+  CTK_D(ctkLogger);
+  return d->Logger->isFatalEnabled(); 
 }
 
 

+ 7 - 24
Libs/Core/ctkLogger.h

@@ -26,8 +26,10 @@
 #include <QSqlDatabase>
 
 // CTK includes
+#include <ctkPimpl.h>
 #include "CTKCoreExport.h"
 
+class ctkLoggerPrivate;
 class CTK_CORE_EXPORT ctkLogger : public QObject
 {
   Q_OBJECT
@@ -38,46 +40,27 @@ public:
   
   void debug ( QString s );
   void info ( QString s );
-  void notice ( QString s );
+  void trace ( QString s );
   void warn ( QString s );
-  void warning ( QString s );
   void error ( QString s );
-  void crit ( QString s );
-  void critical ( QString s );
-  void alert ( QString s );
-  void emerg ( QString s );
-  void emergercy ( QString s );
   void fatal ( QString s );
 
   void setDebug();
   void setInfo();
-  void setNotice();
-  void setWarn();
-  void setWarning();
+  void setTrace();
   void setError();
-  void setCrit();
-  void setCritical();
-  void setAlert();
-  void setEmerg();
-  void setEmergercy();
+  void setWarn();
   void setFatal();
 
   bool isDebugEnabled();
   bool isInfoEnabled();
-  bool isNoticeEnabled();
+  bool isTraceEnabled();
   bool isWarnEnabled();
-  bool isWarningEnabled();
   bool isErrorEnabled();
-  bool isCritEnabled();
-  bool isCriticalEnabled();
-  bool isAlertEnabled();
-  bool isEmergEnabled();
-  bool isEmergercyEnabled();
   bool isFatalEnabled();
 
 private:
-  class ctkInternal;
-  ctkInternal *Internal;
+  CTK_DECLARE_PRIVATE(ctkLogger);
 };
 
 #endif

+ 1 - 1
Libs/Core/target_libraries.cmake

@@ -7,5 +7,5 @@
 SET(target_libraries
   QT_LIBRARIES
   BFD_LIBRARIES
-  log4cpp_LIBRARIES
+  log4qt_LIBRARIES
   )

+ 40 - 15
Libs/DICOM/Core/ctkDICOMQuery.cpp

@@ -59,7 +59,9 @@ public:
   ~ctkDICOMQueryPrivate();
   QString CallingAETitle;
   QString CalledAETitle;
+  QString Host;
   int Port;
+  DcmSCU SCU;
 
 };
 
@@ -110,6 +112,16 @@ const QString& ctkDICOMQuery::calledAETitle()
   CTK_D(ctkDICOMQuery);
   return d->CalledAETitle;
 }
+void ctkDICOMQuery::setHost ( QString host )
+{
+  CTK_D(ctkDICOMQuery);
+  d->Host = host;
+}
+const QString& ctkDICOMQuery::host()
+{
+  CTK_D(ctkDICOMQuery);
+  return d->Host;
+}
 void ctkDICOMQuery::setPort ( int port ) 
 {
   CTK_D(ctkDICOMQuery);
@@ -124,22 +136,35 @@ int ctkDICOMQuery::port()
 
 
 //------------------------------------------------------------------------------
-void ctkDICOMQuery::query(QSqlDatabase database, QString callingAETitle, QString calledAETitle, int port )
+void ctkDICOMQuery::query(QSqlDatabase database )
 {
+  CTK_D(ctkDICOMQuery);
   QSqlDatabase db = database;
-    OFString patientsName, patientID, patientsBirthDate, patientsBirthTime, patientsSex,
-      patientComments, patientsAge;
-
-    OFString studyInstanceUID, studyID, studyDate, studyTime,
-      accessionNumber, modalitiesInStudy, institutionName, performingPhysiciansName, referringPhysician, studyDescription;
-
-    OFString seriesInstanceUID, seriesDate, seriesTime,
-      seriesDescription, bodyPartExamined, frameOfReferenceUID,
-      contrastAgent, scanningSequence;
-    OFString instanceNumber;
-
-  // db.commit();
-  // db.close();
-
+  
+  OFList<OFString> transferSyntaxes;
+  transferSyntaxes.push_back ( UID_LittleEndianExplicitTransferSyntax );
+  transferSyntaxes.push_back ( UID_BigEndianExplicitTransferSyntax );
+  transferSyntaxes.push_back ( UID_LittleEndianImplicitTransferSyntax );
+
+  d->SCU.addPresentationContext ( UID_FINDStudyRootQueryRetrieveInformationModel, transferSyntaxes );
+  d->SCU.setAETitle ( this->callingAETitle().toStdString() );
+  d->SCU.setPeerAETitle ( this->calledAETitle().toStdString() );
+  d->SCU.setPeerHostName ( this->host().toStdString() );
+  if ( !d->SCU.initNetwork().good() ) 
+    {
+    std::cerr << "Error initializing the network" << std::endl;
+    }
+  d->SCU.negotiateAssociation();
+  OFString abstractSyntax;
+  OFString transferSyntax;
+  if ( d->SCU.sendECHORequest ( 0 ).good() )
+    {
+    std::cout << "ECHO Sucessful" << std::endl;
+    } 
+  else
+    {
+    std::cerr << "ECHO Failed" << std::endl;
+    }
+  d->SCU.closeAssociation ( DUL_PEERREQUESTEDRELEASE );
 }
 

+ 3 - 1
Libs/DICOM/Core/ctkDICOMQuery.h

@@ -46,11 +46,13 @@ public:
   const QString& callingAETitle();
   void setCalledAETitle ( QString calledAETitle );
   const QString& calledAETitle();
+  void setHost ( QString host );
+  const QString& host();
   void setPort ( int port );
   int port();
   
   /// Query a remote DICOM Image Store SCP
-  void query(QSqlDatabase database, QString callingAETitle, QString calledAETitle, int port );
+  void query(QSqlDatabase database);
 
 private:
   CTK_DECLARE_PRIVATE(ctkDICOMQuery);

+ 3 - 3
SuperBuild.cmake

@@ -102,7 +102,7 @@ ctkMacroGetAllNonCTKTargetLibraries("${ALL_TARGET_LIBRARIES}" NON_CTK_DEPENDENCI
 # ExternalProjects
 #
 SET(external_projects
-  log4cpp
+  log4qt
   KWStyle
   PythonQt
   DCMTK
@@ -129,7 +129,7 @@ ExternalProject_Add(${proj}
   INSTALL_COMMAND ""
   DEPENDS
     # Mandatory dependencies
-    ${log4cpp_DEPENDS}
+    ${log4qt_DEPENDS}
     # Optionnal dependencies
     ${QtMobility_DEPENDS}
     ${kwstyle_DEPENDS}
@@ -224,7 +224,7 @@ ExternalProject_Add(${proj}
     -DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR}    # FindPythonQt expects PYTHON_INCLUDE_DIR variable to be defined
     -DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY}        # FindPythonQt expects PYTHON_LIBRARY variable to be defined
     -DPYTHONQT_INSTALL_DIR:PATH=${PYTHONQT_INSTALL_DIR} # FindPythonQt expects PYTHONQT_INSTALL_DIR variable to be defined
-    -Dlog4cpp_DIR:PATH=${log4cpp_DIR} # Findlog4cpp expects a log4cpp_DIR variable to be defined
+    -Dlog4qt_DIR:PATH=${log4qt_DIR} # Findlog4qt expects a log4qt_DIR variable to be defined
   SOURCE_DIR ${CTK_SOURCE_DIR}
   BINARY_DIR ${CTK_BINARY_DIR}/CTK-build
   BUILD_COMMAND ""