creaImageIO::SetGimmickDebugMessageLevel(9);
*/
- int image_type = GIMMICK_3D_IMAGE_SELECTION;
+ int min_dim = GIMMICK_2D_IMAGE_SELECTION;
+ int max_dim = GIMMICK_3D_IMAGE_SELECTION;
int threads = 1;
creaImageIO::WxGimmickReaderDialog w(0,
_T("Select image(s) - Gimmick! (c) CREATIS-LRMN 2008"),
wxDefaultPosition,
wxSize(1200,800),
- image_type,
+ min_dim,
+ max_dim,
threads);
w.ShowModal();
std::cout << "$$$$ "<<std::endl;
std::vector<vtkImageData*> images;
- w.GetSelectedImages(images);
+ w.GetSelectedImages(images,3);
crea::VtkBasicSlicer(images.front());
images.front()->Delete();
#include <creaImageIOGimmick.h>
#include <creaImageIOTreeView.h>
#include <creaImageIOSystem.h>
+
//#include <map>
#include <vtkImageData.h>
/// Finalize
virtual void Finalize();
-
- virtual void GetSelectedImages(std::vector<vtkImageData*>& s) {}
+ ///Returns the selected Images and validates to see if they comply with the given parameter(<4D)
+ vtkImageData* GetSelectedImage(int dim);
+ ///Adds the selected Images to the given vector and validates to see if they comply with the given parameter (4D)
+ virtual void GetSelectedImages(std::vector<vtkImageData*>& s, int dim) {}
+
virtual void GetSelectedFiles(std::vector<std::string>& s) {}
/// Create the tree views
#include <creaImageIOTreeHandler.h>
#include <creaImageIOSystem.h>
+#include <vtkImageData.h>
namespace creaImageIO
{
///Removes selected nodes on given level
virtual void RemoveSelected( int )
{ GimmickError("INTERNAL ERROR : TreeView::RemoveSelected not overloaded");}
+
+ ///Validates the selected images
+ virtual void ValidateSelectedImages()
+ { GimmickError("INTERNAL ERROR : TreeView::ValidateSelected not overloaded");}
+ ///Returns the selected data as vtkImageData
+ vtkImageData* GetSelectedImage(int dim)
+ { GimmickError("INTERNAL ERROR : TreeView::GetSelectedImage not overloaded");}
+ ///Returns the selected data as a vector of vtkImageData (4D)
+ virtual void GetSelectedImages(std::vector<vtkImageData*>& s, int dim)
+ { GimmickError("INTERNAL ERROR : TreeView::GetSelectedImages not overloaded");}
protected:
TreeHandler* GetTreeHandler() { return mTreeHandler; }
mGimmick = new Gimmick();
mGimmick->Initialize();
- int image_type = GIMMICK_3D_IMAGE_SELECTION;
+ int min_dim = GIMMICK_2D_IMAGE_SELECTION;
+ int max_dim = GIMMICK_3D_IMAGE_SELECTION;
mView = new WxGimmickView(mGimmick,
this,
-1,
wxDefaultPosition,
size,
- image_type,
+ min_dim,
+ max_dim,
threads);
mView->Initialize();
}
wxString title,
const wxPoint& pos,
const wxSize& size,
- int image_type,
+ int min_dim,
+ int max_dim,
int threads)
: wxDialog( parent,
id,
TVID,
wxDefaultPosition,
size,
- image_type,
+ min_dim,
+ max_dim,
threads);
mView->Initialize();
}
delete mGimmick;
}
}
-
+
+
//================================================================
BEGIN_EVENT_TABLE(WxGimmickReaderDialog, wxDialog)
- END_EVENT_TABLE()
+
+ END_EVENT_TABLE()
//================================================================
wxString title,
const wxPoint& pos,
const wxSize& size,
- int image_type = GIMMICK_3D_IMAGE_SELECTION,
+ int image_min_type = GIMMICK_2D_IMAGE_SELECTION,
+ int image_max_type = GIMMICK_3D_IMAGE_SELECTION,
int threads = 0);
Gimmick* GetGimmick() { return mGimmick; }
~WxGimmickReaderDialog();
- void GetSelectedImages(std::vector<vtkImageData*>& s)
- { mView->GetSelectedImages(s); }
+
+ //===============================================================================================
+ //Image Selection
+ //===============================================================================================
+ vtkImageData* GetSelectedImage(int dim)
+ { return mView->GetSelectedImage(dim); }
+ void GetSelectedImages(std::vector<vtkImageData*>& s, int dim)
+ { mView->GetSelectedImages(s, dim); }
+
+
void GetSelectedFiles(std::vector<std::string>& s)
{ mView->GetSelectedFiles(s); }
void OnSelChanged(EventType& event);
void OnContextualMenu(EventType& event);
void OnMenuTest(wxCommandEvent& event);
+ // void OnValid(wxCommandEvent& event);
// void OnButtonOk(wxCommandEvent& event);
// void OnButtonCancel(wxCommandEvent& event);
wxWindow *parent,
const wxWindowID id,
const wxPoint& pos, const wxSize& size,
- int image_type,
+ int min_dim,
+ int max_dim,
int number_of_threads)
: wxPanel(parent,id,pos,size),
GimmickView(gimmick),
}
//======================================================================
+ /// Returns the selected Images so that they comply with the given parameter(<4D)
+ vtkImageData* WxGimmickView::GetSelectedImage(int dim)
+ {
+ return NULL;
+ }
-
+ //======================================================================
+ /// Returns the selected Images so that they comply with the given parameter(4D)
+ void WxGimmickView::GetSelectedImages(std::vector<vtkImageData*>& s, int dim)
+ {
+
+ //GetTreeViewMap()["Local database"]->GetImageData()
+ //return NULL ;
+
+ }
//=================================================
void WxGimmickView::CreateIconList()
wxWindow *parent,
const wxWindowID id,
const wxPoint& pos, const wxSize& size,
- int image_type = GIMMICK_3D_IMAGE_SELECTION,
+ int min_dim = GIMMICK_2D_IMAGE_SELECTION,
+ int max_dim = GIMMICK_3D_IMAGE_SELECTION,
int number_of_threads = 0);
/// Virtual destructor
virtual ~WxGimmickView();
+ /// Returns the selected Images so that they comply with the given parameter(<4D)
+ ///(overloaded from GimmickView)
+ vtkImageData* GetSelectedImage(int dim);
+ /// Returns the selected Images so that they comply with the given parameter(4D)
+ //(overloaded from GimmickView)
+ void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
+
protected:
/// Creates the tool bar
void CreateToolBar();
/// (overloaded from GimmickView)
void CreateTreeView( TreeHandler* );
+
private:
/// The ToolBar and the tools
wxToolBar* mToolBar;
#include <creaImageIOWxTreeView.h>
#include <creaImageIOSystem.h>
#include <wx/splitter.h>
-
+int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData))
+{
+ // inverse the order
+ if (item1 < item2)
+ return -1;
+ if (item1 > item2)
+ return 1;
+
+ return 0;
+}
namespace creaImageIO
{
//=====================================================================
" Level "<<level+1
<<std::endl);
if (level<mLevelList.size()-1) UpdateLevel( level + 2 );
+ if (level==mLevelList.size()-1) ValidateSelectedImages ();
+
+ }
+ //================================================================
+
+//================================================================
+ void WxTreeView::OnColClick(wxListEvent& event)
+ {
+ /*
+ //Obtain the column name and the level that needs to be organized
+ int colNum=event.m_col;
+ GimmickMessage(1,
+ " Column " <<event.m_col
+ <<std::endl);
+
+
+ wxObject* ctrl = event.GetEventObject();
+ unsigned int level = 0;
+ for (level = 0; level<mLevelList.size(); ++level)
+ {
+ if ( GetCtrl(level) == ctrl ) break;
+ }
+
+ wxBusyCursor busy;
+ std::vector<tree::Node*> sel=GetSelected(level+1);
+
+ tree::Node* nodes[20];
+
+ int l = level - 1;
+
+ // to speed up inserting we hide the control temporarily
+ GetCtrl(level)->Hide();
+ GetCtrl(level)->DeleteAllItems();
+
+ std::vector<tree::Node*>::iterator i;
+ int num=0;
+ for (i=sel.begin(); i!=sel.end(); ++i)
+ {
+
+ //Adds columns
+ GetTreeHandler()->LoadChildren(*i,1);
+ tree::Node::ChildrenListType::reverse_iterator j;
+
+ for (j = (*i)->GetChildrenList().rbegin();
+ j!= (*i)->GetChildrenList().rend();
+ ++j)
+ {
+ nodes[num]=*j;
+ num++;
+ }
+ }
+
+ //Sorting elements
+ int k, m;
+ tree::Node* index;
+
+
+ for (k=1; k<num; ++k)
+ {
+ index = nodes[k];
+ m = k;
+ GimmickMessage(1,
+ "Comparison Key 1: "
+ <<(nodes[m-1])->GetAttribute(mLevelList[level].key[colNum-1])
+ <<"Comparison Key 2: "<<(index)->GetAttribute(mLevelList[level].key[colNum-1])
+ <<std::endl);
+ while ((m > 0) && ((nodes[m-1])->GetAttribute(mLevelList[level].key[colNum-1]) >
+ (index)->GetAttribute(mLevelList[level].key[colNum-1])))
+ {
+ nodes[m] = nodes[m-1];
+ m = m - 1;
+ }
+ nodes[m] = index;
+ }
+
+ for (m=0; m<num; ++m)
+ {
+ tree::Node* node=nodes[m];
+ wxListItem item;
+ item.SetMask(wxLIST_MASK_STATE |
+ wxLIST_MASK_TEXT |
+ // wxLIST_MASK_IMAGE |
+ wxLIST_MASK_DATA |
+ // wxLIST_MASK_WIDTH |
+ wxLIST_MASK_FORMAT
+ );
+
+ long id = GetCtrl(level)->InsertItem(item);
+ int n;
+ if ((node)->GetChildrenLoaded())
+ {
+ n=(node)->GetChildrenList().size();
+ }
+ else
+ {
+ n= GetTreeHandler()->GetNumberOfChildren(node);
+ }
+ std::ostringstream oss;
+
+ oss << n;
+ std::string s(oss.str());
+ GetCtrl(level)->SetItem(id,0, crea::std2wx(s));
+ GetCtrl(level)->SetColumnWidth(0, wxLIST_AUTOSIZE );
+
+ for (int k=1; k<GetCtrl(level)->GetColumnCount(); k++)
+ {
+ std::string val = (node)->GetAttribute(mLevelList[level].key[k-1]);
+ if (val.size()==0) val = "?";
+ GetCtrl(level)->SetItem(id,k, crea::std2wx(val));
+ GetCtrl(level)->SetColumnWidth(k, wxLIST_AUTOSIZE );
+
+ }
+
+ }
+
+
+ GetCtrl(level)->Show();
+*/
+ }
+ //================================================================
+
+ void WxTreeView::ValidateSelectedImages()
+ {
+ GimmickMessage(1,
+ "Hello World Validate"
+ <<std::endl);
+ /*
+ MyEvent event( MyCommandEvent, 0 );
+ wxString bar( wxT("This is a Foo_DoFirstThing event") );
+ event.SetText( bar );
+ wxPostEvent( this, event );
+ */
+
}
+
//================================================================
+ vtkImageData* WxTreeView::GetSelectedImage(int dim)
+ {
+ /*
+ wxArrayTreeItemIds id;
+ // TO DO : TEST THAT STYLE IS MULTIPLE
+ unsigned int nb = mTreeListCtrl->GetSelections(id);
+ f.clear();
+
+ // Collect the brute vector of Image nodes
+ std::vector<DicomNode*> im;
+ for (unsigned int i=0; i<nb; ++i)
+ {
+ TreeItemData *data =
+ (TreeItemData *)mTreeListCtrl->GetItemData(id[i]);
+ if ((data) && (data->IsDicomNode()))
+ {
+ if (data->GetDicomNode()->GetType()==DicomNode::Image)
+ {
+ im.push_back ( data->GetDicomNode() );
+ }
+ else if (data->GetDicomNode()->GetType()==DicomNode::Series)
+ {
+ DicomNode::ChildrenListType::iterator j;
+ for (j =data->GetDicomNode()->GetChildrenList().begin();
+ j!=data->GetDicomNode()->GetChildrenList().end();
+ j++)
+ {
+ im.push_back ( *j );
+ }
+ }
+ }
+ }
+ // Create the output data
+ if (im.size()==1)
+ {
+ // Only one image : give it
+ vtkImageData* out = vtkImageData::New();
+ out->ShallowCopy(mReader.GetImage(im.front()->ImageGetFullFileName()));
+ f.push_back( out );
+ }
+ else if (im.size()>1)
+ {
+ vtkImageData* first = mReader.GetImage( im.front()->ImageGetFullFileName() );
+ if (first->GetDataDimension()==2)
+ {
+ // n2D to 3D
+ vtkImageData* out = vtkImageData::New();
+ out->CopyStructure(first);
+ out->SetScalarType(first->GetScalarType());
+ int ext[6];
+ first->GetExtent(ext);
+ ext[5] = im.size();
+ out->SetExtent(ext);
+ // LG : TODO : Z Spacing ?
+
+ out->AllocateScalars();
+
+ //first->Print(std::cout);
+ // out->Print(std::cout);
+
+ int dim[3];
+ first->GetDimensions(dim);
+ unsigned long imsize =
+ ( (unsigned long)first->GetScalarPointer(0,1,0)
+ - (unsigned long)first->GetScalarPointer(0,0,0))
+ *dim[1];
+
+ int slice = 0;
+ std::vector<DicomNode*>::iterator it;
+ for (it=im.begin(); it!=im.end(); ++it)
+ {
+ //std::cout << "copying slice "<<slice <<std::endl;
+ vtkImageData* cur = mReader.GetImage( (*it)->ImageGetFullFileName() );
+
+ void* src = cur->GetScalarPointer(0,0,0);
+ void* dst = out->GetScalarPointer(0,0,slice);
+ // std::cout << "src="<<src<<std::endl;
+ // std::cout << "dst="<<dst<<std::endl;
+ // std::cout << "siz="<<imsize<<std::endl;
+ memcpy(dst,src,imsize);
+
+ slice++;
+ }
+ f.push_back(out);
+ }
+ else
+ {
+ // n3D
+ std::vector<DicomNode*>::iterator it;
+ for (it=im.begin(); it!=im.end(); ++it)
+ {
+ vtkImageData* out = vtkImageData::New();
+ out->ShallowCopy(mReader.GetImage((*it)->ImageGetFullFileName()));
+ f.push_back(out);
+ }
+ }
+ }
+ */
+ return NULL;
+ }
+
+ void WxTreeView::GetSelectedImages(std::vector<vtkImageData*>& s, int dim)
+ {
+
+ }
BEGIN_EVENT_TABLE(WxTreeView, wxPanel)
/*
EVT_SIZE(MyFrame::OnSize)
EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, MyListCtrl::OnActivated)
EVT_LIST_ITEM_FOCUSED(LIST_CTRL, MyListCtrl::OnFocused)
- EVT_LIST_COL_CLICK(LIST_CTRL, MyListCtrl::OnColClick)
EVT_LIST_COL_RIGHT_CLICK(LIST_CTRL, MyListCtrl::OnColRightClick)
+ */
+ EVT_LIST_COL_CLICK(-1, WxTreeView::OnColClick)
+ /*
EVT_LIST_COL_BEGIN_DRAG(LIST_CTRL, MyListCtrl::OnColBeginDrag)
EVT_LIST_COL_DRAGGING(LIST_CTRL, MyListCtrl::OnColDragging)
EVT_LIST_COL_END_DRAG(LIST_CTRL, MyListCtrl::OnColEndDrag)
///Removes selected nodes on given level
virtual void RemoveSelected( int );
- /// Callback for selection change
+ /// Callback for selection change
void OnSelected(wxListEvent& event);
+ /// Callback for selection change
+ void OnColClick(wxListEvent& event);
+
private:
/// The struct holding the data for one level
/// such as the vector of attribute keys corresponding to the columns
struct LevelType
{
- // The
+ // The List Control
wxListCtrl* wxCtrl;
wxSplitterWindow* wxSplitter;
std::vector<std::string> key;
wxListCtrl* GetCtrl(int l) { return mLevelList[l].wxCtrl; }
/// return the wxSplitter of one level
wxSplitterWindow* GetSplitter(int l) { return mLevelList[l].wxSplitter; }
-
+ /// Gets the user selected data from the level passed as a parameter
std::vector<tree::Node*> GetSelected(int level);
-
-
+ ///Validates the selected images
+ void ValidateSelectedImages();
+ ///Returns the selected data as vtkImageData
+ vtkImageData* GetSelectedImage(int dim);
+ ///Returns the selected data as vtkImageData
+ void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
// Updates the view of a level given the selected items of upper level
// Recursive method
//=====================================================================
} // EO namespace creaImageIO
-
-
+/*
+class MyEvent: public wxCommandEvent
+{
+public:
+ MyEvent( wxEventType commandType = MyCommandEvent, int id = 0 )
+ : wxCommandEvent(commandType, id) { }
+
+ // You *must* copy here the data to be transported
+ MyEvent( const MyEvent &event )
+ : wxCommandEvent(event) { this->SetText( event.GetText() ); }
+
+ // Required for sending with wxPostEvent()
+ wxEvent* Clone() const { return new MyEvent(*this); }
+
+ wxString GetText() const { return m_Text; }
+ void SetText( const wxString& text ) { m_Text = text; }
+
+private:
+ wxString m_Text;
+};
+*/
#endif // USE_WIDGETS
// EOF
#endif