From: caballero Date: Tue, 24 Feb 2009 16:37:10 +0000 (+0000) Subject: Added validation function (visible in ok button being enabled or not) X-Git-Tag: EED.02Oct2009~170 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=2f0e50f69eb904d629cf8db62eb9a4094db93097;p=creaImageIO.git Added validation function (visible in ok button being enabled or not) --- diff --git a/appli/TestWxGimmickReaderDialog/main.cxx b/appli/TestWxGimmickReaderDialog/main.cxx index 8149724..4ce9a54 100644 --- a/appli/TestWxGimmickReaderDialog/main.cxx +++ b/appli/TestWxGimmickReaderDialog/main.cxx @@ -31,6 +31,7 @@ bool myApp::OnInit( ) 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, @@ -40,6 +41,7 @@ bool myApp::OnInit( ) wxSize(1200,800), min_dim, max_dim, + output_dim, threads); w.ShowModal(); diff --git a/src2/creaImageIOGimmickView.h b/src2/creaImageIOGimmickView.h index 8407a91..a521f8d 100644 --- a/src2/creaImageIOGimmickView.h +++ b/src2/creaImageIOGimmickView.h @@ -13,6 +13,10 @@ #define GIMMICK_3D_IMAGE_SELECTION 3 #define GIMMICK_4D_IMAGE_SELECTION 4 +#define NATIVE 0 +#define _2D 2 +#define _3D 3 + namespace creaImageIO { diff --git a/src2/creaImageIOTreeView.h b/src2/creaImageIOTreeView.h index fe29f3b..de4f7f2 100644 --- a/src2/creaImageIOTreeView.h +++ b/src2/creaImageIOTreeView.h @@ -10,6 +10,7 @@ namespace creaImageIO /** * \ingroup View */ + //===================================================================== //===================================================================== @@ -40,17 +41,37 @@ namespace creaImageIO ///Returns the selected data as a vector of vtkImageData (4D) virtual void GetSelectedImages(std::vector& 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 diff --git a/src2/creaImageIOWxGimmickReaderDialog.cpp b/src2/creaImageIOWxGimmickReaderDialog.cpp index 2bf1661..c12cd06 100644 --- a/src2/creaImageIOWxGimmickReaderDialog.cpp +++ b/src2/creaImageIOWxGimmickReaderDialog.cpp @@ -11,6 +11,7 @@ namespace creaImageIO const wxSize& size, int min_dim, int max_dim, + int out_dim, int threads) : wxDialog( parent, id, @@ -44,6 +45,7 @@ namespace creaImageIO size, min_dim, max_dim, + out_dim, threads); mView->Initialize(); } @@ -83,11 +85,20 @@ namespace creaImageIO } } + ///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() //================================================================ diff --git a/src2/creaImageIOWxGimmickReaderDialog.h b/src2/creaImageIOWxGimmickReaderDialog.h index 9526d37..54f929c 100644 --- a/src2/creaImageIOWxGimmickReaderDialog.h +++ b/src2/creaImageIOWxGimmickReaderDialog.h @@ -5,12 +5,13 @@ #include #include - +#include "wx/wx.h" namespace creaImageIO { /** * \ingroup GUI */ + //===================================================================== //===================================================================== class /*CREAIMAGEIO_EXPORT*/ WxGimmickReaderDialog : public wxDialog @@ -22,8 +23,9 @@ namespace creaImageIO 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; } @@ -48,11 +50,13 @@ namespace creaImageIO 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; @@ -70,11 +74,11 @@ namespace creaImageIO }; // class WxGimmickReaderDialog //===================================================================== - - + } // EO namespace creaImageIO + #endif // USE_WIDGETS // EOF #endif diff --git a/src2/creaImageIOWxGimmickView.cpp b/src2/creaImageIOWxGimmickView.cpp index edcc684..cec329b 100644 --- a/src2/creaImageIOWxGimmickView.cpp +++ b/src2/creaImageIOWxGimmickView.cpp @@ -63,6 +63,7 @@ namespace creaImageIO 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), @@ -99,6 +100,10 @@ namespace creaImageIO //Gimmick mGimmick=gimmick; + mSelectionMaxDimension=max_dim; + mSelectionMinDimension=min_dim; + mOutputDimension=out_dim; + // Create the views CreateTreeViews(); @@ -181,6 +186,10 @@ namespace creaImageIO name<<"'"<SetMaxDimension(mSelectionMaxDimension); + view->SetMinDimension(mSelectionMinDimension); + view->SetOutputDimension(mOutputDimension); // TO DO : TEST THAT A VIEW WITH SAME NAME IS NOT // ALREADY IN THE MAP diff --git a/src2/creaImageIOWxGimmickView.h b/src2/creaImageIOWxGimmickView.h index 1da2729..235c8f0 100644 --- a/src2/creaImageIOWxGimmickView.h +++ b/src2/creaImageIOWxGimmickView.h @@ -32,6 +32,7 @@ namespace creaImageIO 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(); @@ -84,6 +85,12 @@ namespace creaImageIO 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; diff --git a/src2/creaImageIOWxTreeView.cpp b/src2/creaImageIOWxTreeView.cpp index 1b3d20d..bd64078 100644 --- a/src2/creaImageIOWxTreeView.cpp +++ b/src2/creaImageIOWxTreeView.cpp @@ -308,7 +308,7 @@ namespace creaImageIO //================================================================ - void WxTreeView::OnSelected(wxListEvent& event) + void WxTreeView::OnSelectedChanged(wxListEvent& event) { GimmickDebugMessage(1, GetTreeHandler()->GetTree().GetLabel() @@ -454,15 +454,99 @@ namespace creaImageIO void WxTreeView::ValidateSelectedImages() { - GimmickMessage(1, - "Hello World Validate" - < sel=GetSelected(level+1); + if(sel.size()>0) + { + std::vector::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:" + <> 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 !" + <GetMaxDimension()) + { + GimmickMessage(1,"Selecting "<ProcessEvent( event ); + } } @@ -625,9 +709,10 @@ BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl) 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) diff --git a/src2/creaImageIOWxTreeView.h b/src2/creaImageIOWxTreeView.h index 6ffc1f5..3571c11 100644 --- a/src2/creaImageIOWxTreeView.h +++ b/src2/creaImageIOWxTreeView.h @@ -35,13 +35,12 @@ namespace creaImageIO 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 @@ -71,35 +70,19 @@ namespace creaImageIO // 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