creaImageIOWxGimmickView.h

Go to the documentation of this file.
00001 #ifndef __creaImageIOWxGimmickView_h_INCLUDED__
00002 #define __creaImageIOWxGimmickView_h_INCLUDED__
00003 
00004 #ifdef USE_WXWIDGETS
00005 
00006 #include <creaImageIOGimmickView.h>
00007 #include <creaImageIOWxViewer.h>
00008 #include <creaImageIOWxGimmickTools.h>
00009 #include <creaImageIOListener.h>
00010 #include <creaWx.h>
00011 #include <time.h>
00012 
00013 #include "wx/progdlg.h"
00014 
00015 #include "wx/wx.h"
00016 #include <wx/splitter.h>
00017 #include <wx/toolbar.h> 
00018 #include <wx/tbarbase.h> 
00019 #include <wx/notebook.h>
00020 
00021 namespace creaImageIO
00022 {
00026   //=====================================================================
00027   
00028   //=====================================================================
00030 
00031   class WxGimmickView : public wxPanel, virtual public GimmickView
00032   {
00033   public:
00034     
00035     typedef int EventType;
00036         OutStrGimmick m_out;
00037     
00039     WxGimmickView(boost::shared_ptr<Gimmick>, 
00040                   wxWindow *parent, 
00041                   const wxWindowID id,
00042                   const wxPoint& pos, const wxSize& size,
00043                   int min_dim = GIMMICK_2D_IMAGE_SELECTION,
00044                   int max_dim = GIMMICK_3D_IMAGE_SELECTION,
00045                   int number_of_threads = 0);
00047     virtual ~WxGimmickView();
00048     
00051     void GetSelectedFiles(std::vector<std::string>& s);
00052     
00054         void getSelectedFiles(std::vector<OutStrGimmick> &outG, std::vector< std::string> out_infos, bool mult = false, const std::string out_model = "");
00055 
00058     void GetSelectedImages(std::vector<vtkImageData*>& s, int dim);
00059     void GetSelectedImagesInVector(std::vector<vtkImageData*>& s, int dim);
00060 
00061 
00064     //(overloaded from GimmickView) 
00065     void GetImages(int dim, const std::vector<std::string>& files, 
00066                    std::vector<vtkImageData*>& s);
00067     
00069     //(overloaded from GimmickView)
00070     void OnSelectionChange(const std::vector<tree::Node*>& s, 
00071                            bool isSelection, int selection, bool mProcess);
00073     void StopPlayer(){mViewer->StopPlayer();}
00075     void AddIgnoreFile(tree::Node* toRemove);
00077     void ClearSelection();
00079     void CopyFiles(const std::vector<std::string>& filenames);
00081     void AddDir(std::string dirName);
00082     
00083     
00085     void ReadImageThreaded(const std::vector<tree::Node*>& sel);
00086 
00088         void OnSaveSettingsCallback(const std::string& copyPath,
00089           const std::string& dbPath,
00090           const std::string& syncEvent,
00091           const std::string& syncFreq);
00092         
00094         void OnListenerCallback(const std::string& drive, bool addFiles, bool removeFiles);
00095 
00097         void OnDriveMount(bool mount);
00098 
00100         void StartListeningThread();
00101 
00103         void StopListeningThread();
00104 
00106         void OnFieldsEdited(tree::Node* node, const std::string& name, const std::string& key, const std::string& val);
00107 
00109         void GetVisibleAttributes(std::vector<std::string>& shown,std::vector<std::string>& nShown, int level);
00110 
00112         void OnAttributesChanged(const std::vector<std::string>& nShown, int level);
00113 
00114 
00115   protected:
00117     void CreateToolBar(); 
00118     
00121     void CreateTreeView( TreeHandler* );
00122     
00123     
00124   private:
00125           wxBoxSizer *mbottom_sizer;
00126           wxBoxSizer    *msizer;
00130     bool mConstructed;
00132     wxToolBar*         mToolBar;
00133     wxToolBarToolBase* mToolAddFile;
00134     wxToolBarToolBase* mToolAddDir;
00135     wxToolBarToolBase* mToolRemove;
00136     wxToolBarToolBase* mToolAddDatabase;
00137     wxToolBarToolBase* mToolHelp;
00138         wxToolBarToolBase* mToolSynchronize;
00139         wxToolBarToolBase* mToolSettings;
00140         wxToolBarToolBase* mToolTools;
00141     
00142     wxSplitterWindow* mSplitter;
00143     wxPanel*          mBottomPanel;
00144     wxStaticText *    mText;
00145     wxNotebook*       mNotebook;
00146     
00148     wxImageList *    mIcon;
00149     void CreateIconList();
00150     
00151     boost::shared_ptr<Gimmick> mGimmick;
00152                 
00153         Listener* mListener;
00154 
00156     void OnAddFiles(wxCommandEvent& event);
00157 
00159     void OnAddDir(wxCommandEvent& event);
00160 
00162     void OnRemove(wxCommandEvent& event);
00163 
00165     void OnSynchronize(wxCommandEvent& event);
00166 
00168     void OnSettings(wxCommandEvent& event);
00169 
00171     void OnTools(wxCommandEvent& event);
00172 
00174     void OnImportExport(wxCommandEvent& event);
00175 
00176         // Import Images from an archive
00177         void ImportImages();
00178 
00179         //Export Images to an archive
00180         void ExportImages();
00181 
00183         void CreateSettingsDialog(wxNotebook* nb, wxDialog* dial);
00184     
00186     void DisplayAddSummary();
00187         time_t  mstart;
00189         bool isNeedRecursive(std::string i_name);
00190 
00192         int NumberFilesToAdd(const std::string &dirpath, bool recursive);
00193     
00195     void OnAddProgress( Gimmick::AddProgress& );
00196 
00197 #if defined(WIN32)
00198 
00199     void OnInternalIdle();
00200 #else
00201         void UpdateWindowUI(long flags = wxUPDATE_UI_NONE);
00202 #endif
00203 
00204         void OnAddDB(wxCommandEvent& event);
00205     
00207         void OnCreateDB(wxCommandEvent& event);
00208 
00209         std::string ExtractName(const std::string &i_name);
00210 
00212         void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys);
00213 
00214         
00216         void DumpTags(const std::string i_filename);
00217  
00219         void ExportToStorage(const std::vector<std::string> i_filenames);
00220  
00222     wxProgressDialog* mProgressDialog;
00223 
00225     int mSelectionMaxDimension;
00226 
00228     int mSelectionMinDimension;
00229 
00231     WxViewer* mViewer;
00232 
00234     tree::Node* mCurImageItemToShow;
00235 
00236     //Pointer holders for images to be shown
00237         std::vector< boost::shared_ptr<ImagePointerHolder> > pointers;
00238 
00239         //kill Progress DialogBar
00240         void killProgress();
00241 
00242     wxString mCurrentDirectory;
00243     
00244     DECLARE_EVENT_TABLE()
00245       };
00246   // EO class WxGimmickView
00247   //=====================================================================
00248 
00249 } // EO namespace creaImageIO
00250 
00251 #endif // USE_WIDGETS
00252 // EOF
00253 #endif