creaImageIOSynchron
creaImageIOTimestampDatabaseHandler
creaImageIOListener
+ creaImageIOPACSConnection
# Abstract views
creaImageIOGimmickView
creaImageIOWxListenerPanel
creaImageIOWxEditFieldsPanel
creaImageIOWxAttributeSelectionPanel
+ creaImageIOWxPACSConnectionPanel
#
BlockScopeWxApp
)
-
OPTION(${LIBRARY_NAME}_BUILD_SHARED
"Build ${LIBRARY_NAME} as a shared library (dynamic) ?" ON)
IF (${LIBRARY_NAME}_BUILD_SHARED)
# Invoke the advanced macro
CREA_ADVANCED_INSTALL_LIBRARY_FOR_CMAKE(${LIBRARY_NAME})
+SET(INPUT_DATA_DIR ${PROJECT_SOURCE_DIR}/src2/data)
+SET(OUTPUT_DATA_DIR ${PROJECT_BINARY_DIR}/data)
+CREA_CPDIR(${INPUT_DATA_DIR} ${OUTPUT_DATA_DIR})
+
#CREA_INSTALL_LIBRARY_FOR_CMAKE(${LIBRARY_NAME})
#-----------------------------------------------------------------------------
# ${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/src2
# ${PROJECT_SOURCE_DIR}/src2/CppSQLite3
- )
\ No newline at end of file
+ )
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
+#ifndef PATH_MAX // If not defined yet : do it
+# define PATH_MAX 2048
+#endif
+
namespace creaImageIO
{
//==============================================================
void Gimmick::Initialize()
{
- std::string i_nameDB = "Local database";
+ std::string i_nameDB = "Local database";
// Create the UserSettings dir if does not exist
CreateUserSettingsDirectory();
// Sets the current directory to the home dir
}
//================================================================
+ //================================================================
+ int Gimmick::GetBinaryDirectory(char *pname, size_t pathsize)
+ {
+
+ #ifdef LINUX
+ /* Oddly, the readlink(2) man page says no NULL is appended. */
+ /* So you have to do it yourself, based on the return value: */
+ pathsize --; /* Preserve a space to add the trailing NULL */
+ long result = readlink("/proc/self/exe", pname, pathsize);
+ if (result > 0)
+ {
+ pname[result] = 0; /* add the #@!%ing NULL */
+
+ if ((access(pname, 0) == 0))
+ return 0; /* file exists, return OK */
+ /*else name doesn't seem to exist, return FAIL (falls
+ through) */
+ }
+ #endif /* LINUX */
+
+ #ifdef WIN32
+ long result = GetModuleFileName(NULL, pname, pathsize);
+ if (result > 0)
+ {
+ /* fix up the dir slashes... */
+ int len = strlen(pname);
+ int idx;
+ for (idx = 0; idx < len; idx++)
+ {
+ if (pname[idx] == '\\') pname[idx] = '/';
+ }
+
+ for (idx = len-1; idx >=0 ; idx--)
+ {
+ if (pname[idx] == '/')
+ {
+ pname[idx+1] = '\0';
+ idx = -1;
+ }
+ }
+
+ if ((access(pname, 0) == 0))
+ return 0; /* file exists, return OK */
+ /*else name doesn't seem to exist, return FAIL (falls
+ through) */
+ }
+ #endif /* WIN32 */
+
+ #ifdef SOLARIS
+ char *p = getexecname();
+ if (p)
+ {
+ /* According to the Sun manpages, getexecname will
+ "normally" return an */
+ /* absolute path - BUT might not... AND that IF it is not,
+ pre-pending */
+ /* getcwd() will "usually" be the correct thing... Urgh!
+ */
+
+ /* check pathname is absolute (begins with a / ???) */
+ if (p[0] == '/') /* assume this means we have an
+ absolute path */
+ {
+ strncpy(pname, p, pathsize);
+ if ((access(pname, 0) == 0))
+ return 0; /* file exists, return OK */
+ }
+ else /* if not, prepend getcwd() then check if file
+ exists */
+ {
+ getcwd(pname, pathsize);
+ long result = strlen(pname);
+ strncat(pname, "/", (pathsize - result));
+ result ++;
+ strncat(pname, p, (pathsize - result));
+
+ if ((access(pname, 0) == 0))
+ return 0; /* file exists, return OK */
+ /*else name doesn't seem to exist, return FAIL
+ (falls through) */
+ }
+ }
+ #endif /* SOLARIS */
+
+ #ifdef MACOSX /* assume this is OSX */
+ /*
+ from http://www.hmug.org/man/3/NSModule.html
+
+ extern int _NSGetExecutablePath(char *buf, unsigned long
+ *bufsize);
+
+ _NSGetExecutablePath copies the path of the executable
+ into the buffer and returns 0 if the path was successfully
+ copied in the provided buffer. If the buffer is not large
+ enough, -1 is returned and the expected buffer size is
+ copied in *bufsize. Note that _NSGetExecutablePath will
+ return "a path" to the executable not a "real path" to the
+ executable. That is the path may be a symbolic link and
+ not the real file. And with deep directories the total
+ bufsize needed could be more than MAXPATHLEN.
+ */
+
+ int status = -1;
+ char *given_path = (char*)malloc(MAXPATHLEN * 2);
+ if (!given_path) return status;
+
+ uint32_t npathsize = MAXPATHLEN * 2;
+ long result = _NSGetExecutablePath(given_path, &npathsize);
+ if (result == 0)
+ { /* OK, we got something - now try and resolve the real path...
+ */
+ if (realpath(given_path, pname) != NULL)
+ {
+ if ((access(pname, 0) == 0))
+ status = 0; /* file exists, return OK */
+ }
+ }
+ free (given_path);
+ return status;
+ #endif /* MACOSX */
+
+ return -1; /* Path Lookup Failed */
+ }
+
//================================================================
const std::string& Gimmick::GetLocalDatabasePath()
{
GimmickError("ERROR CREATING '"<<GetUserSettingsDirectory()<<"'");
}
}
+
+ std::string setDir=GetUserSettingsDirectory();
+ boost::algorithm::replace_all( setDir,
+ VALID_FILE_SEPARATOR ,
+ INVALID_FILE_SEPARATOR);
+ setDir+="localdatabase_Descriptor.txt";
+ if(!boost::filesystem::is_regular_file(setDir))
+ {
+ char name[PATH_MAX];
+ int err = GetBinaryDirectory(name, PATH_MAX);
+ std::string path=name;
+ path=path.substr(0,path.size()-1);
+ path=path.substr(0,path.find_last_of("/"));
+ path+="/data/localdatabase_Descriptor.txt";
+ boost::algorithm::replace_all( path,
+ VALID_FILE_SEPARATOR ,
+ INVALID_FILE_SEPARATOR);
+ boost::filesystem::copy_file(path,setDir);
+ }
}
//========================================================================
///
const std::string& GetHomeDirectory();
const std::string& GetUserSettingsDirectory();
+ int GetBinaryDirectory(char *pname, size_t pathsize);
void CreateUserSettingsDirectory();
const std::string& GetLocalDatabasePath();
const std::string& GetTimestampDatabasePath();
--- /dev/null
+#include <creaImageIOPACSConnection.h>
+#include <cstdlib>
+#include <cstring>
+#include <iostream>
+#include <boost/asio.hpp>
+
+using boost::asio::ip::tcp;
+
+enum { max_length = 3086 };
+using namespace std;
+namespace creaImageIO
+{
+ PACSConnection::PACSConnection(std::string command)
+ {
+ try
+ {
+
+ boost::asio::io_service io_service;
+
+ tcp::resolver resolver(io_service);
+ tcp::resolver::query query(tcp::v4(), "localhost", "3306");
+ tcp::resolver::iterator iterator = resolver.resolve(query);
+
+ tcp::socket s(io_service);
+ s.connect(*iterator);
+
+ size_t request_length = strlen(command.c_str());
+ boost::asio::write(s, boost::asio::buffer(command.c_str(), request_length));
+
+ char reply[max_length];
+ size_t reply_length = boost::asio::read(s,
+ boost::asio::buffer(reply, request_length));
+ std::cout << "Reply is: ";
+ std::cout.write(reply, reply_length);
+ std::cout << "\n";
+ }
+ catch (std::exception& e)
+ {
+ std::cerr << "Exception: " << e.what() << "\n";
+ }
+ }
+}
--- /dev/null
+#ifndef __creaImageIOPACSConnection_h_INCLUDED__
+#define __creaImageIOPACSConnection_h_INCLUDED__
+#include <string>
+
+namespace creaImageIO
+{
+class PACSConnection
+ {
+ public:
+ /// Ctor
+ PACSConnection(std::string command);
+ };// EO PACSConnection
+} // EO namespace creaImageIO
+
+// EOF
+#endif
\ No newline at end of file
#include <creaImageIOWxListenerPanel.h>
#include <creaImageIOWxEditFieldsPanel.h>
#include <creaImageIOWxAttributeSelectionPanel.h>
+#include <creaImageIOWxPACSConnectionPanel.h>
using namespace crea;
// Icons
nb->AddPage( customConfig, crea::std2wx("Customize Configuration") );
//Second page: Creation of Databases
- wxPanel* databaseCreation=new wxPanel(nb);
- nb->AddPage( databaseCreation, crea::std2wx("Create Database") );
+ /*wxPanel* databaseCreation=new wxPanel(nb);
+ nb->AddPage( databaseCreation, crea::std2wx("Create Database") );*/
+
+ //Second page (temporary): Connection to PACS
+ WxPACSConnectionPanel* pacs=new WxPACSConnectionPanel(nb,dial, this);
+ nb->AddPage( pacs, crea::std2wx("Connect to PACS") );
//Third page: CD/DVD Watch
WxListenerPanel* cdWatch=new WxListenerPanel(nb,dial, this, mListener->IsPaused());
_T("E:"),
_T("F:"),
_T("G:") };
- drives=new wxComboBox(this, -1,_T("E:"),wxPoint(100, 10),wxDefaultSize,4,choices);
+ drives=new wxComboBox(this, -1,crea::std2wx("E:"),wxPoint(100, 10),wxDefaultSize,4,choices);
addCheckBox = new wxCheckBox(this, -1, _T("Automatically add images to the database when CD/DVD is mounted?"), wxPoint(5,45) );
addCheckBox->SetValue(true);
--- /dev/null
+#include <creaImageIOWxPACSConnectionPanel.h>
+#include <creaImageIOPACSConnection.h>
+#include <creaImageIOSystem.h>
+
+namespace creaImageIO
+{
+ // CTor
+ WxPACSConnectionPanel::WxPACSConnectionPanel(wxWindow *parent, wxDialog* dial, WxGimmickView* view)
+ : wxPanel( parent,
+ -1, wxDefaultPosition,
+ wxDefaultSize,
+ wxRESIZE_BORDER |
+ wxSYSTEM_MENU |
+ wxCLOSE_BOX |
+ wxMAXIMIZE_BOX |
+ wxMINIMIZE_BOX |
+ wxCAPTION
+ ),
+ dialog(dial),
+ mView(view)
+ {
+ GimmickDebugMessage(1,"WxPACSConnectionPanel::WxPACSConnectionPanel"
+ <<std::endl);
+ wxStaticText * dicId=new wxStaticText(this,-1,_T(" DICOM Identification: "), wxPoint(5,5));
+ wxStaticText * aet=new wxStaticText(this,-1,_T(" AETitle: "), wxPoint(5,25));
+ aeTitle=new wxTextCtrl(this, wxID_ANY, _T("MyAeTitle"), wxPoint(75,25), wxSize(220,20));
+
+ wxStaticText * pn=new wxStaticText(this,-1,_T(" Port Number: "), wxPoint(5,53));
+ pNumber=new wxTextCtrl(this, wxID_ANY, _T("3306"), wxPoint(75,50), wxSize(220,20));
+ wxStaticText * adv1=new wxStaticText(this,-1,_T(" (1 - 131072) "), wxPoint(300,53));
+
+ wxStaticText * ad=new wxStaticText(this,-1,_T(" Address: "), wxPoint(5,80));
+ address=new wxTextCtrl(this, wxID_ANY, _T("localhost"), wxPoint(75,75), wxSize(220,20));
+
+ wxButton *query = new wxButton(this,wxID_ANY,_T("Query PACS Server"), wxPoint(5,110) );
+ Connect( query->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxPACSConnectionPanel::OnQueryPACS );
+
+ Layout();
+ }
+
+ /// Destructor
+ WxPACSConnectionPanel::~WxPACSConnectionPanel()
+ {
+ GimmickDebugMessage(1,"WxPACSConnectionPanel::~WxPACSConnectionPanel"
+ <<std::endl);
+ }
+
+ void WxPACSConnectionPanel::OnQueryPACS(wxCommandEvent& event)
+ {
+ PACSConnection* pc=new PACSConnection(crea::wx2std(aeTitle->GetValue()));
+ //mView->OnListenerCallback(crea::wx2std(drives->GetValue()),addFiles, removeFiles);
+ //dialog->Destroy();
+ }
+
+//======================================================================
+
+//======================================================================
+
+} // EO namespace creaImageIO
+
+
--- /dev/null
+#ifndef __creaImageIOWxPACSConnectionPanel_h_INCLUDED__
+#define __creaImageIOWxPACSConnectionPanel_h_INCLUDED__
+
+#ifdef USE_WXWIDGETS
+#include <creaWx.h>
+#include <creaImageIOWxGimmickView.h>
+
+
+namespace creaImageIO
+{
+ /**
+ * \ingroup GUI
+ */
+ //=====================================================================
+ //=====================================================================
+ class WxPACSConnectionPanel : public wxPanel
+ {
+ public:
+ WxPACSConnectionPanel();
+ WxPACSConnectionPanel(wxWindow *parent,
+ wxDialog* dial,
+ WxGimmickView* view);
+
+ ~WxPACSConnectionPanel();
+ ///Queries the PACS
+ void OnQueryPACS(wxCommandEvent& event);
+
+ private :
+ wxTextCtrl* aeTitle;
+ wxTextCtrl* pNumber;
+ wxTextCtrl* address;
+ wxDialog* dialog;
+ WxGimmickView* mView;
+
+
+ }; // class WxPACSConnectionPanel
+ //=====================================================================
+
+
+} // EO namespace creaImageIO
+
+
+#endif // USE_WIDGETS
+// EOF
+#endif
\ No newline at end of file
--- /dev/null
+<level>
+Root
+O Name Name 4
+<level>
+Patient
+O NumberOfChildren #Series
+D 0x0010 0x0010 4
+D 0x0010 0x0040
+D 0x0010 0x0030
+D 0x0010 0x0020 2
+<level>
+Series
+O NumberOfChildren #Images
+D 0x0008 0x0060 4
+D 0x0008 0x1030
+D 0x0008 0x103E
+D 0x0008 0x0080
+D 0x0008 0x0081
+D 0x0008 0x1010
+D 0x0008 0x1048
+D 0x0008 0x1050
+D 0x0018 0x1030
+D 0x0020 0x0010
+D 0x0008 0x0020
+D 0x0008 0x0030
+D 0x0008 0x0050
+D 0x0008 0x0005
+D 0x0008 0x0021
+D 0x0008 0x0031
+D 0x0020 0x000D
+D 0x0020 0x000E 2
+<level>
+Image
+D 0x0020 0x0013
+D 0x0028 0x0010
+D 0x0028 0x0011
+D 0x0028 0x0012
+D 0x0028 0x0002
+D 0x0028 0x0008
+D 0x0028 0x0004
+D 0x0028 0x0103
+D 0x0020 0x0032
+D 0x0020 0x0037
+D 0x0020 0x1041
+D 0x0028 0x0006
+D 0x0028 0x0030
+D 0x0028 0x0100
+D 0x0028 0x0101
+D 0x0008 0x0008
+D 0x0008 0x0023
+D 0x0008 0x0033
+D 0x0020 0x4000
+D 0x0004 0x1500 4
+D 0x0028 0x1052
+D 0x0028 0x1053
+D 0x0050 0x0004
+D 0x0020 0x0052
+D 0x0008 0x0016
+O FullFileName Full_file_name 2