int min_dim = GIMMICK_2D_IMAGE_SELECTION;
int max_dim = GIMMICK_3D_IMAGE_SELECTION;
+ int output_dim = NATIVE;
int threads = 1;
creaImageIO::WxGimmickReaderDialog w(0,
wxSize(1200,800),
min_dim,
max_dim,
+ output_dim,
threads);
w.ShowModal();
#define GIMMICK_3D_IMAGE_SELECTION 3
#define GIMMICK_4D_IMAGE_SELECTION 4
+#define NATIVE 0
+#define _2D 2
+#define _3D 3
+
namespace creaImageIO
{
/**
* \ingroup View
*/
+
//=====================================================================
//=====================================================================
///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");}
+
+ ///Sets the maximum dimension allowed for selections
+ void SetMaxDimension(int maxdim){ mSelectionMaxDimension=maxdim; }
+ ///Sets the minimum dimension allowed for selections
+ void SetMinDimension(int mindim){ mSelectionMinDimension=mindim; }
+ ///Sets the output dimension desired for selections
+ void SetOutputDimension(int outdim){ mOutputDimension=outdim; }
protected:
TreeHandler* GetTreeHandler() { return mTreeHandler; }
+ ///Gets the maximum dimension allowed for selections
+ int GetMaxDimension(){ return mSelectionMaxDimension; }
+ ///Gets the minimum dimension allowed for selections
+ int GetMinDimension(){ return mSelectionMinDimension; }
+ ///Gets the output dimension desired for selections
+ int GetOutputDimension(){ return mOutputDimension; }
private:
/// The TreeHandler with which it corresponds
TreeHandler* mTreeHandler;
+ //The selection's maximum dimension
+ int mSelectionMaxDimension;
+ //The selection's minimum dimension
+ int mSelectionMinDimension;
+ //The user desired output dimension
+ int mOutputDimension;
};
// EO class TreeView
//=====================================================================
+
} // EO namespace creaImageIO
// EOF
const wxSize& size,
int min_dim,
int max_dim,
+ int out_dim,
int threads)
: wxDialog( parent,
id,
size,
min_dim,
max_dim,
+ out_dim,
threads);
mView->Initialize();
}
}
}
+ ///Callback method on a selection
+ void WxGimmickReaderDialog::OnValid(wxCommandEvent& event)
+ {
+ if (event.GetInt()==0)
+ {mOkButton->Enable(true);}
+ else
+ {mOkButton->Enable(false);}
+ }
+
//================================================================
BEGIN_EVENT_TABLE(WxGimmickReaderDialog, wxDialog)
-
+ EVT_COMMAND(wxID_ANY, 0, WxGimmickReaderDialog::OnValid)
END_EVENT_TABLE()
//================================================================
#include <creaImageIOWxGimmickView.h>
#include <creaWx.h>
-
+#include "wx/wx.h"
namespace creaImageIO
{
/**
* \ingroup GUI
*/
+
//=====================================================================
//=====================================================================
class /*CREAIMAGEIO_EXPORT*/ WxGimmickReaderDialog : public wxDialog
wxString title,
const wxPoint& pos,
const wxSize& size,
- int image_min_type = GIMMICK_2D_IMAGE_SELECTION,
- int image_max_type = GIMMICK_3D_IMAGE_SELECTION,
+ int image_min_dim = GIMMICK_2D_IMAGE_SELECTION,
+ int image_max_dim = GIMMICK_3D_IMAGE_SELECTION,
+ int output_dim = NATIVE,
int threads = 0);
Gimmick* GetGimmick() { return mGimmick; }
void OnSelChanged(EventType& event);
void OnContextualMenu(EventType& event);
void OnMenuTest(wxCommandEvent& event);
- // void OnValid(wxCommandEvent& event);
+ void OnValid(wxCommandEvent& event);
// void OnButtonOk(wxCommandEvent& event);
// void OnButtonCancel(wxCommandEvent& event);
- DECLARE_EVENT_TABLE();
+ DECLARE_EVENT_TABLE()
+
+
private :
Gimmick* mGimmick;
}; // class WxGimmickReaderDialog
//=====================================================================
-
-
+
} // EO namespace creaImageIO
+
#endif // USE_WIDGETS
// EOF
#endif
const wxPoint& pos, const wxSize& size,
int min_dim,
int max_dim,
+ int out_dim,
int number_of_threads)
: wxPanel(parent,id,pos,size),
GimmickView(gimmick),
//Gimmick
mGimmick=gimmick;
+ mSelectionMaxDimension=max_dim;
+ mSelectionMinDimension=min_dim;
+ mOutputDimension=out_dim;
+
// Create the views
CreateTreeViews();
name<<"'"<<std::endl);
// Create the WxTreeView
WxTreeView* view = new WxTreeView(h,mNotebook,-1);
+
+ view->SetMaxDimension(mSelectionMaxDimension);
+ view->SetMinDimension(mSelectionMinDimension);
+ view->SetOutputDimension(mOutputDimension);
// TO DO : TEST THAT A VIEW WITH SAME NAME IS NOT
// ALREADY IN THE MAP
const wxPoint& pos, const wxSize& size,
int min_dim = GIMMICK_2D_IMAGE_SELECTION,
int max_dim = GIMMICK_3D_IMAGE_SELECTION,
+ int out_dim = NATIVE,
int number_of_threads = 0);
/// Virtual destructor
virtual ~WxGimmickView();
void OnAddProgress( Gimmick::AddProgress& );
/// Progress dialog
wxProgressDialog* mProgressDialog;
+ //The selection's maximum dimension
+ int mSelectionMaxDimension;
+ //The selection's minimum dimension
+ int mSelectionMinDimension;
+ //The user desired output dimension
+ int mOutputDimension;
wxString mCurrentDirectory;
//================================================================
- void WxTreeView::OnSelected(wxListEvent& event)
+ void WxTreeView::OnSelectedChanged(wxListEvent& event)
{
GimmickDebugMessage(1,
GetTreeHandler()->GetTree().GetLabel()
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 );
- */
+ int level=mLevelList.size();
+ std::vector<tree::Node*> sel=GetSelected(level+1);
+ if(sel.size()>0)
+ {
+ std::vector<tree::Node*>::iterator i;
+ bool valid=true;
+ std::string row;
+ std::string col;
+ std::string plane;
+
+ //Validation between image sizes
+ for (i=sel.begin(); i!=sel.end() && valid; ++i)
+ {
+ if(i==sel.begin())
+ {
+ row=(*i)->GetAttribute(mLevelList[level-1].key[1]);
+ col=(*i)->GetAttribute(mLevelList[level-1].key[2]);
+ plane=(*i)->GetAttribute(mLevelList[level-1].key[3]);
+ }
+ else
+ {
+ if(((*i)->GetAttribute(mLevelList[level-1].key[1]))!=row ||
+ ((*i)->GetAttribute(mLevelList[level-1].key[2]))!=col ||
+ ((*i)->GetAttribute(mLevelList[level-1].key[3]))!=plane)
+ {
+ valid=false;
+ }
+ }
+ }
+
+ GimmickMessage(1,
+ "State check: Planes:"
+ <<plane<<" Cols: "
+ <<col<<" Rows:"
+ <<row<<" "
+ << std::endl);
+ //Dimention validation
+ //Compatibility with maximum
+ if(valid)
+ {
+ int rows;
+ int cols;
+ int planes;
+ std::string s;
+ std::istringstream t(s);
+ s=row;
+ t >> rows;
+ if(row==""){rows=1;}
+ s=col;
+ t >> cols;
+ if(col==""){cols=1;}
+ s=plane;
+ t >> planes;
+ if(plane==""){planes=1;}
+
+ int dim = 0;
+ if (planes>1) dim=3;
+ else if (cols>1) dim=2;
+ else if (rows>1) dim=1;
+
+ if (dim == 0)
+ {
+ GimmickMessage(1,
+ "Unknown image dimension : cannot select !"
+ <<dim<<" "
+ <<plane<<" "
+ <<col<<" "
+ <<row<<" "
+ << std::endl);
+ valid= false;
+ }
+ else if (dim>GetMaxDimension())
+ {
+ GimmickMessage(1,"Selecting "<<dim<<"D images is not allowed !"
+ << std::endl);
+ valid= false;
+ }
+ if ( dim == GetMaxDimension() )
+ {
+ GimmickMessage(1,"Cannot add this image to selection : would result in a "<<dim+1<<"D image !" << std::endl);
+ valid= false;
+ }
+ }
+
+ //Send an event telling wether the selection is valid or not
+ wxCommandEvent event( 0, GetId() );
+ event.SetEventObject( this );
+ if(valid)
+ {event.SetInt(0);}
+ else
+ {event.SetInt(1);}
+ GetEventHandler()->ProcessEvent( event );
+ }
}
EVT_LIST_SET_INFO(LIST_CTRL, MyListCtrl::OnSetInfo)
#endif
*/
- EVT_LIST_ITEM_SELECTED(-1, WxTreeView::OnSelected)
- /*
- EVT_LIST_ITEM_DESELECTED(LIST_CTRL, MyListCtrl::OnDeselected)
+ EVT_LIST_ITEM_SELECTED(-1, WxTreeView::OnSelectedChanged)
+
+ EVT_LIST_ITEM_DESELECTED(-1, WxTreeView::OnSelectedChanged)
+ /*
EVT_LIST_KEY_DOWN(LIST_CTRL, MyListCtrl::OnListKeyDown)
EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, MyListCtrl::OnActivated)
EVT_LIST_ITEM_FOCUSED(LIST_CTRL, MyListCtrl::OnFocused)
virtual void RemoveSelected( int );
/// Callback for selection change
- void OnSelected(wxListEvent& event);
+ void OnSelectedChanged(wxListEvent& event);
- /// Callback for selection change
+ /// Callback for column click
void OnColClick(wxListEvent& event);
-
- private:
+ private:
/// The struct holding the data for one level
/// Holds the wx control and other data
/// such as the vector of attribute keys corresponding to the columns
// Updates the view of a level given the selected items of upper level
// Recursive method
virtual void RecursiveUpdateLevel( int );
-
+
+
DECLARE_EVENT_TABLE()
};
// EO class WxTreeView
//=====================================================================
-
+
+
+
} // 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