소스 검색

Added log4cpp and ctkLogger. Started DICOM query class, but is only an empty shell currently.

Daniel Blezek 15 년 전
부모
커밋
f25a765019

+ 10 - 3
Applications/ctkDICOM/ctkDICOM.cpp

@@ -32,6 +32,10 @@
 // STD includes
 #include <iostream>
 
+void usage ( char* prog ) {
+  std::cerr << "Usage: " << prog << " <DatabaseFilename> <DatabaseScriptFilename>\n";
+}
+
 int main(int argc, char** argv)
 {
   QApplication app(argc, argv);
@@ -52,16 +56,19 @@ int main(int argc, char** argv)
   if (!myCTK.openDatabase( datbaseFileName ))
     {
     std::cerr << "Error when opening the data base file: " << datbaseFileName
-              << " error: " << myCTK.GetLastError().toStdString();
+      << " error: " << myCTK.GetLastError().toStdString() << std::endl;
+      usage ( argv[0] );
     return EXIT_FAILURE;
     }
+  /*
   if (!myCTK.initializeDatabase(datbaseScriptFileName))
     {
     std::cerr << "Error when initializing the data base: " << datbaseScriptFileName
-              << " error: " << myCTK.GetLastError().toStdString();
+      << " error: " << myCTK.GetLastError().toStdString() << std::endl;;
+      usage ( argv[0] );
     return EXIT_FAILURE;
     }
-
+*/
   ctkDICOMModel model;
   model.setDatabase(myCTK.database());
   

+ 20 - 0
CMakeExternals/log4cpp.cmake

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

+ 9 - 1
Libs/Core/CMakeLists.txt

@@ -6,6 +6,10 @@ 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}" )
+endif()
 #
 # See CTK/CMake/ctkMacroBuildLib.cmake for details
 #
@@ -14,6 +18,7 @@ SET(KIT_export_directive "CTK_CORE_EXPORT")
 
 # Additional directories to include
 SET(KIT_include_directories
+  ${log4cpp_INCLUDE_DIR}
   )
   
 # Source files
@@ -30,6 +35,8 @@ SET(KIT_SRCS
   ctkAbstractLibraryFactory.tpp
   ctkDependencyGraph.cpp
   ctkDependencyGraph.h
+  ctkLogger.cpp
+  ctkLogger.h
   ctkModelTester.cpp
   ctkModelTester.h
   ctkPimpl.h
@@ -49,9 +56,10 @@ ENDIF()
 
 # Headers that should run through moc
 SET(KIT_MOC_SRCS
+  ctkLogger.h 
   ctkModelTester.h
   ctkTransferFunction.h
-  )
+)
 
 # UI files
 SET(KIT_UI_FORMS

+ 55 - 0
Libs/Core/ctkLogger.cpp

@@ -0,0 +1,55 @@
+/*=========================================================================
+
+  Library:   CTK
+ 
+  Copyright (c) 2010  Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ 
+=========================================================================*/
+
+// Qt includes
+#include <QDebug>
+#include <QSqlDatabase>
+
+#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>
+
+
+class ctkLogger::ctkInternal {
+public:
+  ctkInternal( QString name ) : Logger ( ::log4cpp::Category::getInstance ( name.toStdString().c_str() ) ) {
+  }
+  log4cpp::Category& Logger;
+};
+
+ctkLogger::ctkLogger(QString name, QObject* _parent): Superclass(_parent)
+{
+  this->Internal = new ctkInternal ( name );
+}
+
+ctkLogger::~ctkLogger()
+{
+  delete this->Internal;
+}
+

+ 44 - 0
Libs/Core/ctkLogger.h

@@ -0,0 +1,44 @@
+/*=========================================================================
+
+  Library:   CTK
+ 
+  Copyright (c) 2010  Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ 
+=========================================================================*/
+
+#ifndef __ctkLogger_h
+#define __ctkLogger_h
+
+// Qt includes 
+#include <QObject>
+#include <QSqlDatabase>
+
+// CTK includes
+#include "CTKCoreExport.h"
+
+class CTK_CORE_EXPORT ctkLogger : public QObject
+{
+  Q_OBJECT
+public:
+  typedef QObject Superclass;
+  explicit ctkLogger ( QString name, QObject* parent = 0 );
+  virtual ~ctkLogger ();
+  
+private:
+  class ctkInternal;
+  ctkInternal *Internal;
+};
+
+#endif

+ 1 - 0
Libs/Core/target_libraries.cmake

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

+ 3 - 0
Libs/DICOM/Core/CMakeLists.txt

@@ -24,6 +24,8 @@ SET(KIT_include_directories
 SET(KIT_SRCS
   ctkDICOM.cpp
   ctkDICOM.h
+  ctkDICOMQuery.cpp
+  ctkDICOMQuery.h
   ctkDICOMIndexer.cpp
   ctkDICOMIndexer.h
   ctkDICOMModel.cpp
@@ -34,6 +36,7 @@ SET(KIT_SRCS
 SET(KIT_MOC_SRCS
   ctkDICOM.h
   ctkDICOMModel.h
+  ctkDICOMQuery.h
   )
 
 # UI files

+ 145 - 0
Libs/DICOM/Core/ctkDICOMQuery.cpp

@@ -0,0 +1,145 @@
+/*=========================================================================
+
+  Library:   CTK
+ 
+  Copyright (c) 2010  Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ 
+=========================================================================*/
+
+// Qt includes
+#include <QSqlQuery>
+#include <QSqlRecord>
+#include <QVariant>
+#include <QDate>
+#include <QStringList>
+#include <QSet>
+#include <QFile>
+#include <QDirIterator>
+#include <QFileInfo>
+#include <QDebug>
+
+// ctkDICOM includes
+#include "ctkDICOMQuery.h"
+
+// DCMTK includes
+#ifndef WIN32
+  #define HAVE_CONFIG_H 
+#endif
+#include "dcmtk/dcmnet/dimse.h"
+#include "dcmtk/dcmnet/diutil.h"
+
+#include <dcmtk/dcmdata/dcfilefo.h>
+#include <dcmtk/dcmdata/dcfilefo.h>
+#include <dcmtk/dcmdata/dcdeftag.h>
+#include <dcmtk/dcmdata/dcdatset.h>
+#include <dcmtk/ofstd/ofcond.h>
+#include <dcmtk/ofstd/ofstring.h>
+#include <dcmtk/ofstd/ofstd.h>        /* for class OFStandard */
+#include <dcmtk/dcmdata/dcddirif.h>   /* for class DicomDirInterface */
+
+#include <dcmtk/dcmnet/scu.h>
+
+//------------------------------------------------------------------------------
+class ctkDICOMQueryPrivate: public ctkPrivate<ctkDICOMQuery>
+{
+public:
+  ctkDICOMQueryPrivate();
+  ~ctkDICOMQueryPrivate();
+  QString CallingAETitle;
+  QString CalledAETitle;
+  int Port;
+
+};
+
+//------------------------------------------------------------------------------
+// ctkDICOMQueryPrivate methods
+
+//------------------------------------------------------------------------------
+ctkDICOMQueryPrivate::ctkDICOMQueryPrivate()
+{
+}
+
+//------------------------------------------------------------------------------
+ctkDICOMQueryPrivate::~ctkDICOMQueryPrivate()
+{
+}
+
+//------------------------------------------------------------------------------
+// ctkDICOMQuery methods
+
+//------------------------------------------------------------------------------
+ctkDICOMQuery::ctkDICOMQuery()
+{
+}
+
+//------------------------------------------------------------------------------
+ctkDICOMQuery::~ctkDICOMQuery()
+{
+}
+
+/// Set methods for connectivity
+void ctkDICOMQuery::setCallingAETitle ( QString callingAETitle )
+{
+  CTK_D(ctkDICOMQuery);
+  d->CallingAETitle = callingAETitle;
+}
+const QString& ctkDICOMQuery::callingAETitle() 
+{
+  CTK_D(ctkDICOMQuery);
+  return d->CallingAETitle;
+}
+void ctkDICOMQuery::setCalledAETitle ( QString calledAETitle )
+{
+  CTK_D(ctkDICOMQuery);
+  d->CalledAETitle = calledAETitle;
+}
+const QString& ctkDICOMQuery::calledAETitle()
+{
+  CTK_D(ctkDICOMQuery);
+  return d->CalledAETitle;
+}
+void ctkDICOMQuery::setPort ( int port ) 
+{
+  CTK_D(ctkDICOMQuery);
+  d->Port = port;
+}
+int ctkDICOMQuery::port()
+{
+  CTK_D(ctkDICOMQuery);
+  return d->Port;
+}
+
+
+
+//------------------------------------------------------------------------------
+void ctkDICOMQuery::query(QSqlDatabase database, QString callingAETitle, QString calledAETitle, int port )
+{
+  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();
+
+}
+

+ 59 - 0
Libs/DICOM/Core/ctkDICOMQuery.h

@@ -0,0 +1,59 @@
+/*=========================================================================
+
+  Library:   CTK
+ 
+  Copyright (c) 2010  Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ 
+=========================================================================*/
+
+#ifndef __ctkDICOMQuery_h
+#define __ctkDICOMQuery_h
+
+// Qt includes 
+#include <QObject>
+#include <QSqlDatabase>
+
+// CTK includes
+#include <ctkPimpl.h>
+
+#include "CTKDICOMCoreExport.h"
+
+class ctkDICOMQueryPrivate;
+class CTK_DICOM_CORE_EXPORT ctkDICOMQuery : public QObject
+{
+  Q_OBJECT
+  Q_PROPERTY(QString callingAETitle READ callingAETitle WRITE setCallingAETitle);
+  Q_PROPERTY(QString calledAETitle READ calledAETitle WRITE setCallingAETitle);
+  Q_PROPERTY(int port READ port WRITE setPort);
+public:
+  explicit ctkDICOMQuery();
+  virtual ~ctkDICOMQuery();
+  
+  /// Set methods for connectivity
+  void setCallingAETitle ( QString callingAETitle );
+  const QString& callingAETitle();
+  void setCalledAETitle ( QString calledAETitle );
+  const QString& calledAETitle();
+  void setPort ( int port );
+  int port();
+  
+  /// Query a remote DICOM Image Store SCP
+  void query(QSqlDatabase database, QString callingAETitle, QString calledAETitle, int port );
+
+private:
+  CTK_DECLARE_PRIVATE(ctkDICOMQuery);
+};
+
+#endif

+ 1 - 0
SuperBuild.cmake

@@ -95,6 +95,7 @@ ctkMacroGetAllNonCTKTargetLibraries("${ALL_TARGET_LIBRARIES}" NON_CTK_DEPENDENCI
 # ExternalProjects
 #
 SET(external_projects
+  log4cpp
   KWStyle
   PythonQt
   DCMTK