SUBDIRS(wxGimmick)
SUBDIRS(TestWxGimmickReaderDialog)
SUBDIRS(TestGimmickReaderDialog)
- SUBDIRS(TestWxGimmickReaderDialogJava)
+ SUBDIRS(TestWxSimpleView)
+ #SUBDIRS(TestWxGimmickReaderDialogJava)
#LSE (BUILD_V2)
# SUBDIRS(TestWxGimmickDialog)
#ENDIF (BUILD_V2)
int threads = 1;
+
creaImageIO::WxGimmickReaderDialog w(
0,
-1,
--- /dev/null
+
+IF(WIN32)
+ ADD_EXECUTABLE(TestWxSimpleDlg WIN32 main)
+ SET_TARGET_PROPERTIES(TestWxSimpleDlg PROPERTIES LINK_FLAGS /subsystem:console )
+ELSE(WIN32)
+ ADD_EXECUTABLE(TestWxSimpleDlg MACOSX_BUNDLE main)
+ENDIF(WIN32)
+
+TARGET_LINK_LIBRARIES( TestWxSimpleDlg creaImageIO )
+
+INSTALL_TARGETS(/bin/ TestWxSimpleDlg )
--- /dev/null
+#include <creaImageIOSystem.h>
+#include <creaWx.h>
+#include <creaImageIOWxSimpleDlg.h>
+#include <creaVtkBasicSlicer.h>
+
+// Just to test the selection of file(s), directory or from creaImageIO database.
+class myApp : public wxApp
+{
+public:
+ bool OnInit( );
+ int OnExit() { return true; }
+};
+
+IMPLEMENT_APP(myApp);
+
+CREA_WXMAIN_WITH_CONSOLE
+
+bool myApp::OnInit( )
+{
+ wxApp::OnInit();
+#ifdef __WXGTK__
+ //See http://www.wxwindows.org/faqgtk.htm#locale
+ setlocale(LC_NUMERIC, "C");
+#endif
+ wxInitAllImageHandlers();
+
+ creaImageIO::SetGimmickMessageLevel(5);
+ creaImageIO::SetGimmickDebugMessageLevel(0);
+
+ creaImageIO::WxSimpleDlg x(0);
+ x.ShowModal();
+ std::vector <vtkImageData*> test = x.getImagesSelected();
+ if(test.size() >0)
+ {
+ crea::VtkBasicSlicer(test.front());
+ }
+
+ return false;
+}
+
+
# E.G. TO bbfy "toto.xml" ADD "toto" (NO EXTENSION)
# THE PATH MUST BE RELATIVE TO THE src FOLDER
${CMAKE_CURRENT_BINARY_DIR}/src/bbcreaImageIOGimmick.xml
- )
+#${CMAKE_CURRENT_BINARY_DIR}/src/bbImagesReader.xml
+)
+
#===========================================================================
#===========================================================================
IF (BUILD_V2)
+
CONFIGURE_FILE(bbcreaImageIOGimmick.xml_v2
${CMAKE_CURRENT_BINARY_DIR}/bbcreaImageIOGimmick.xml
COPYONLY)
--- /dev/null
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+#include "bbImagesReader.h"
+#include "bbcreaImageIOPackage.h"
+namespace bbcreaImageIO
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaImageIO,ImagesReader)
+BBTK_BLACK_BOX_IMPLEMENTATION(ImagesReader,bbtk::AtomicBlackBox);
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+void ImagesReader::Process()
+{
+
+ creaImageIO::WxSimpleDlg dlg(0,crea::std2wx(bbGetInputTitle()));
+ dlg.ShowModal();
+ bbSetOutputOut( dlg.getImagesSelected());
+
+
+}
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+void ImagesReader::bbUserSetDefaultValues()
+{
+
+}
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+void ImagesReader::bbUserInitializeProcessing()
+{
+
+}
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+void ImagesReader::bbUserFinalizeProcessing()
+{
+
+}
+}
+// EO namespace bbcreaImageIO
+
+
--- /dev/null
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+#ifndef __bbImagesReader_h_INCLUDED__
+#define __bbImagesReader_h_INCLUDED__
+#include "bbcreaImageIO_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "creaImageIOWxSimpleDlg.h"
+
+namespace bbcreaImageIO
+{
+
+class bbcreaImageIO_EXPORT ImagesReader
+ :
+ public bbtk::AtomicBlackBox
+{
+ BBTK_BLACK_BOX_INTERFACE(ImagesReader,bbtk::AtomicBlackBox);
+typedef std::vector<vtkImageData*> OutputImagesType;
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+ BBTK_DECLARE_INPUT(Title,std::string);
+ BBTK_DECLARE_OUTPUT(Out,OutputImagesType);
+ BBTK_PROCESS(Process);
+ void Process();
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImagesReader,bbtk::AtomicBlackBox);
+BBTK_NAME("ImagesReader");
+BBTK_AUTHOR("frederic.cervenansky@creatis.insa-lyon.fr");
+BBTK_DESCRIPTION("ImagesRedear is a simple application to select file(s) or directory or data from Gimmick database and display them. It handles DICOM,jpg,tif,png,bmp and mhd.");
+BBTK_CATEGORY("image;reader;dicom");
+typedef std::vector<vtkImageData*> OutputImagesType;
+BBTK_INPUT(ImagesReader,Title,"Title of the dialog",std::string,"");
+BBTK_OUTPUT(ImagesReader,Out,"The selected images",OutputImagesType,"");
+BBTK_END_DESCRIBE_BLACK_BOX(ImagesReader);
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+}
+// EO namespace bbcreaImageIO
+
+#endif // __bbImagesReader_h_INCLUDED__
+
--- /dev/null
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!--==========================================================================
+ STARTS THE DESCRIPTION OF THE BLACK BOX -->
+<blackbox name="ImagesReader">
+ <!--========================================================================
+ THE BOX DOCUMENTATION -->
+ <author>cervenansky.frederic@creatis.insa-lyon.fr</author>
+ <description>
+ ImagesRedear is a simple application to select file(s) or directory or data from Gimmick database and display them. It handles DICOM,jpg,tif,png,bmp and mhd."
+ </description>
+ <category>image;reader;dicom</category>
+
+ <!--========================================================================
+ #include directives to be put in the .h generated
+ There must be one tag per file to include -->
+ <include>creaImageIOWxSimpleView.h</include>
+ <!--========================================================================
+ INPUTS/OUTPUTS DECLARATION -->
+
+ <input name="Title" type="std::string" description="Title of the dialog"/>
+ <typedef>
+ <PRE>
+ typedef std::vector<vtkImageData*> OutputImagesType;</PRE>
+ </typedef>
+
+ <output name="Out" type="OutputImagesType" description="The selected images"/>
+
+ <!--========================================================================
+ PROCESS section -->
+
+ <process>
+ <PRE>
+ creaImageIO::WxSimpleView dlg(0,crea::std2wx(bbGetInputTitle()));
+ dlg.ShowModal();
+ if (bbGetInputOutput()==0)
+ {
+ bbSetOutputOut( x.getImagesSelected());
+ }
+
+ </PRE>
+ </process>
+
+ <!--======================================================================
+ CONSTRUCTORS / DESTRUCTORS (OPTIONAL) -->
+
+ <constructor>
+ <PRE>
+ bbSetInputImageDimension(3);
+ bbSetInputTitle("Select image(s)");
+ bbSetInputOutput(0);
+ bbSetOutputOut(0);
+ </PRE>
+ </constructor>
+
+
+ <!-- THE COPY-CONSTRUCTION METHOD BODY : -->
+ <copyconstructor>
+ <PRE>
+ bbSetOutputOut(0);
+ </PRE>
+ </copyconstructor>
+
+ <!-- THE DESTRUCTION METHOD BODY -->
+ <destructor>
+ <PRE>
+ std::vector<vtkImageData*>::iterator i;
+ for (i=bbGetOutputOut2().begin();i!=bbGetOutputOut2().end();++i) (*i)->Delete();
+ </PRE>
+ </destructor>
+
+
+
+</blackbox>
+
# Image Readers
FILE(GLOB SOURCES_CREAIMAGEIO_IMG_READER
+ creaImageIOSimpleView.cpp
creaImageIOAbstractImageReader.cpp
creaImageIOImageReader.cpp
creaImageIOUltrasonixImageReader.cpp
# The wxWidgets-based components
if (USE_WXWIDGETS)
FILE(GLOB SOURCES_CREAIMAGEIO_WX
+ creaImageIOWxSimpleDlg.cpp
creaImageIOWxAttributeSelectionPanel.cpp
creaImageIOWxCustomizeConfigPanel.cpp
creaImageIOWxDescriptorPanel.cpp
--- /dev/null
+#include "creaImageIOSimpleView.h"
+
+namespace creaImageIO
+{
+
+ bool SimpleView::readFile(std::vector<std::string> i_filenames, std::vector<vtkImageData *> &i_img)
+ {
+ bool bresult, bfinal = true;
+ ImageReader *mReader = new ImageReader();
+ std::vector<std::string>::iterator it = i_filenames.begin();
+ for (; it != i_filenames.end(); it++)
+ {
+ bresult = mReader->CanRead((*it).c_str());
+ if(bresult)
+ {
+ i_img.push_back(mReader->ReadImage((*it).c_str()));
+ }
+ else
+ {
+ bfinal = false;
+ }
+ }
+ delete mReader;
+ return bfinal;
+
+ }
+
+ bool SimpleView::readDirectory(const std::string i_pathname, std::vector<vtkImageData *> &i_imgs)
+ {
+ bool bresult = true;
+ ImageReader *mReader = new ImageReader();
+
+ bresult = boost::filesystem::exists( i_pathname );
+ if (bresult)
+ {
+ boost::filesystem::directory_iterator itr(i_pathname);
+ boost::filesystem::directory_iterator end_itr;
+ for(;itr != end_itr; ++itr)
+ {
+ if (!boost::filesystem::is_directory(itr->status()))
+ {
+ if( mReader->CanRead(itr->string()) )
+ {
+ i_imgs.push_back( mReader->ReadImage(itr->string()) );
+ }
+ }
+ }
+ }
+ return bresult;
+ }
+}
+
--- /dev/null
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem.hpp>
+#include <boost/utility.hpp>
+#include "creaImageIOImageReader.h"
+
+namespace creaImageIO
+{
+ class SimpleView
+ {
+ public:
+ /// Ctor
+ SimpleView(){}
+
+ ///Dtor
+ ~SimpleView(){}
+
+ /// read file(s) and return a vector of vtkImageData
+ bool readFile( std::vector<std::string> i_filenames, std::vector< vtkImageData *> &i_img);
+
+ /// read a directory and return a vector of vtkImageData
+ bool readDirectory(const std::string i_pathname, std::vector< vtkImageData *> &i_imgs);
+
+ };
+}
\ No newline at end of file
--- /dev/null
+#include "creaImageIOWxSimpleDlg.h"
+#include "creaImageIOWxGimmickReaderDialog.h"
+
+
+namespace creaImageIO
+{
+
+ ///Ctor
+ WxSimpleDlg::WxSimpleDlg(wxWindow *parent, wxString i_title)
+ : wxDialog(parent, -1,_T("DISPLAY IMAGES"), wxDefaultPosition, wxSize(230,150))
+ {
+ if(!i_title.empty())
+ {
+ this->SetTitle(i_title);
+ }
+ // Button to select file(s)
+ wxButton *fileBut = new wxButton(this, -1,_T("Select a file to display"), wxPoint(10,7) );
+ Connect( fileBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxSimpleDlg::OnReadFile );
+
+ // Button to select directory
+ wxButton *directoryBut = new wxButton(this, -1,_T("Select a directory to display"), wxPoint(10,40) );
+ Connect( directoryBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxSimpleDlg::OnReadDirectory );
+
+ // button to select creaImageIO
+ wxButton *gimmickBut = new wxButton(this, -1,_T("Select Gimmick"), wxPoint(10,70) );
+ Connect( gimmickBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxSimpleDlg::OnReadGimmick );
+
+ //TO DO Button to select Bruker directory
+
+ Layout();
+
+ }
+//////////////////////////////////////////////////////////////////////
+// //
+//////////////////////////////////////////////////////////////////////
+ void WxSimpleDlg::OnReadFile(wxCommandEvent& event)
+ {
+ wxFileDialog* FD = new wxFileDialog( 0, _T("Select file"), _T(""), _T(""), crea::std2wx("*"), wxOPEN |wxFD_MULTIPLE, wxDefaultPosition);
+
+ if (FD->ShowModal()==wxID_OK)
+ {
+ wxArrayString wxArray;
+ FD->GetPaths(wxArray);
+ if(wxArray.size() >0)
+ {
+ std::vector<std::string> files;
+ for( int i = 0; i < wxArray.GetCount(); i++)
+ {
+ files.push_back( crea::wx2std(wxArray[i]));
+ }
+ if(!m_view.readFile(files,m_results))
+ {
+ //TO DO WARNING MESSAGE;
+ }
+ }
+ else
+ {
+ // TO DO WARNING MESSAGES
+ }
+ }
+ Close();
+ }
+
+ //////////////////////////////////////////////////////////////////////
+// //
+//////////////////////////////////////////////////////////////////////
+
+ void WxSimpleDlg::OnReadDirectory(wxCommandEvent &event)
+ {
+ long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
+ wxDirDialog* FD = new wxDirDialog( 0, _T("Select the directory to display"), "", style);
+
+ if (FD->ShowModal()==wxID_OK)
+ {
+ if(! m_view.readDirectory(crea::wx2std(FD->GetPath()),m_results))
+ {
+ //TO DO WARNING MESSAGE;
+ }
+ }
+ Close();
+ }
+
+ //////////////////////////////////////////////////////////////////////
+// //
+//////////////////////////////////////////////////////////////////////
+
+ void WxSimpleDlg::OnReadGimmick(wxCommandEvent &event)
+ {
+ // Run Gimmick
+ WxGimmickReaderDialog dlg(0,-1, "localdatabase_Descriptor.dscp",
+ "Local Database", _T("Select image(s) - Gimmick! (c) CREATIS-LRMN 2008"),
+ wxDefaultPosition,
+ wxSize(810,750),
+ GIMMICK_2D_IMAGE_SELECTION,
+ GIMMICK_3D_IMAGE_SELECTION,
+ _3D,
+ 1);
+ dlg.ShowModal();
+ if (dlg.GetReturnCode() == wxID_OK)
+ {
+ dlg.GetSelectedImages(m_results,3);
+ dlg.OnExit();
+ }
+ Close();
+ }
+
+
+ //////////////////////////////////////////////////////////////////////
+// Return the results vector //
+//////////////////////////////////////////////////////////////////////
+ std::vector<vtkImageData*> WxSimpleDlg::getImagesSelected()
+ {
+ return m_results;
+ }
+}
+
--- /dev/null
+#include "creaImageIOSimpleView.h"
+#include <creaWx.h>
+
+
+namespace creaImageIO
+{
+ /**
+ * \ingroup View
+ */
+
+ /// Simple Wxwidgets interface to select file(s) or directory or from creaImageIO database to display
+ class CREAIMAGEIO_EXPORT WxSimpleDlg : public wxDialog
+ {
+ public:
+ /// Ctor
+ WxSimpleDlg( wxWindow *parent, wxString i_title ="");
+
+ ///Dtor
+ ~WxSimpleDlg(){};
+
+
+ /// Callback to read file(s)
+ void OnReadFile(wxCommandEvent& event);
+
+ /// Callback to read directory, no recursive
+ void OnReadDirectory(wxCommandEvent &event);
+
+ /// Callback to select from creaImageIO database
+ void OnReadGimmick(wxCommandEvent &event);
+
+ /// return a vtkImageData vector of selected images, if available
+ std::vector<vtkImageData*> getImagesSelected();
+
+ private:
+
+ /// interface to read data
+ SimpleView m_view;
+
+ /// vtkImageData vector
+ std::vector<vtkImageData*> m_results;
+ };
+}
\ No newline at end of file