]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOWxTreeView.h
Added attribute selection functionality.
[creaImageIO.git] / src2 / creaImageIOWxTreeView.h
index 6ffc1f52173df045143d4ea55c93130ba355169c..a0f6b658d062b032214c81f313bde350f1a98127 100644 (file)
@@ -12,6 +12,7 @@
 
 namespace creaImageIO
 {
+
   /**
    * \ingroup View
    */
@@ -23,7 +24,8 @@ namespace creaImageIO
     {
     public:
       /// Ctor
-      WxTreeView(TreeHandler*, wxWindow* parent, const wxWindowID id);
+      WxTreeView(TreeHandler*, GimmickView*, 
+                wxWindow* parent, const wxWindowID id);
       /// Virtual destructor
       virtual ~WxTreeView();
 
@@ -31,16 +33,54 @@ namespace creaImageIO
       /// Updates the view of a level given the selected items of upper level
       virtual void UpdateLevel( int );
 
-         ///Removes selected nodes on given level
-         virtual void RemoveSelected( int );
+      ///Removes selected nodes on given level
+      virtual void RemoveSelected();
+
+         ///Returns the last selected level
+         virtual unsigned int GetLastSelectedLevel(){return mLastLevel;}
 
-         /// Callback for selection change
-      void OnSelected(wxListEvent& event);
+      /// Callback for item selection
+      void OnItemSelected(wxListEvent& event);
 
-         /// Callback for selection change
+      /// Callback for item deselection
+      void OnItemDeSelected(wxListEvent& event);
+      
+      /// Callback for column click
       void OnColClick(wxListEvent& event);
+      
+      /// Callback when the user needs the items sorted
+      void OnPopupSort(wxCommandEvent& event);
+      
+      ///Callback when the user need the items filtered
+      void OnPopupFilter(wxCommandEvent& event);
+
+         ///Callback when the user needs the item copied to the local disk
+      void OnLocalCopy(wxCommandEvent& event);
 
+         ///Callback when the user needs to edit a field
+      void OnEditField(wxCommandEvent& event);
+      
+      ///Callback on mouse click
+      void OnMouseClick(wxMouseEvent& event);
 
+         /// Displays a menu for items
+         void OnItemMenu(wxListEvent &event);
+         
+         /// Gets the attributes that are being shown and the ones that have been blocked on a specific level
+         void GetAttributes(std::vector<std::string>& areShown, std::vector<std::string>& notShown, int level);
+
+         ///Sets the non visible attributes and refreshes the GUI
+         void SetNonVisibleAttributes(const std::vector<std::string>& notShown, int level);
+
+         ///Creates a new listctrl
+         void CreateCtrl(std::vector<std::string>& notShown, int nlevel);
+  
+         ///Returns true if the attribute passed as a parameter is visible or not
+         bool IsAttributeVisible(const std::string& val, int level);
+      
+      /// Actual processing of item selection/deselection 
+      /// Called by OnItemSelected and OnItemDeSelected
+      //      void ProcessItem
     private:
       /// The struct holding the data for one level
       /// Holds the wx control and other data
@@ -51,6 +91,18 @@ namespace creaImageIO
        wxListCtrl* wxCtrl;
        wxSplitterWindow* wxSplitter;
        std::vector<std::string> key;
+       //The vector of not shown attributes
+       std::vector<std::string> notShownAtts;
+       // The vector of currently selected nodes of the level
+       std::vector<tree::Node*> Selected;
+       // True iff the vector Selected is up to date
+       bool SelectedUpToDate;
+       // The column used for sorting
+       unsigned int SortColumn;
+       ///Boolean that defines the direction of the sort
+       ///True is ascending order and false is descending
+       bool SortAscending;
+       // 
       };
       /// The vector of levels : one for each level of the tree      
       std::vector<LevelType> mLevelList;
@@ -59,47 +111,85 @@ namespace creaImageIO
       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
+      //Returns the maximum number of levels
+      int GetNumberOfLevels(){ return mLevelList.size(); }
+      /// Gets the user selected data from the level passed as a parameter
+      /// Updates the vector if necessary
+      const std::vector<tree::Node*>& GetSelected(int level);
+      /// Set the bool SelectedUpToDate for level l
+      void SetSelectedUpToDate(int l, bool v) { mLevelList[l].SelectedUpToDate = v; }
+      /// Get the bool SelectedUpToDate for level l
+      bool GetSelectedUpToDate(int l) { return mLevelList[l].SelectedUpToDate; }
+       ///Validates the selected images
+      void ValidateSelectedImages(bool isSelection);   
+      ///Gets selected filenames
+      void GetSelectedAsString(std::vector<std::string>&s);
+         ///Gets the filenames of the given nodes and returns them on the given vector. Is recursive.
+         void GetFilenamesAsString(const std::vector<tree::Node*>& nodes, std::vector<std::string>&s);
+      /// Gets the next nodes on the list, be it up(true) or down(false).
+      void GetNodes(std::vector<tree::Node*>& nodes, bool direction);
+      /// Updates the view of a level given the selected items of upper level
+      /// Recursive method
       virtual void RecursiveUpdateLevel( int );
+      ///Sets the color of a selected item
+      void SetColor(int level, int item);
+      ///Creates the color palette for the first level
+      void CreateColorPalette();
+      ///Selects all the elements of a level 
+      void SelectAll(int level);
+      ///UnSelects all the elements of a level 
+      void UnSelectAll(int level);
+
+         void OnKeyDown(wxListEvent &event);
+      /// Sorts the level
+      void SortLevel(int level);
+      
+      /// Currently Selected Column
+      int mColumnSelected;
+      ///The last selected item on the list (left click)
+      long mLastSelected;
+
+         ///The last selected item on the list (right click)
+         long mLastRightSelected;
+
+         ///The last selected level (by right click)
+         int mLastRightLevel;
+      ///The color map
+      typedef std::map<tree::Node*,wxColour> ColorMap;
+      typedef std::pair<tree::Node*,wxColour> NodeColorPair;
+      ColorMap mColorMap;
+      ///Initial color palette
+      std::vector<std::string> mColorPalette;
+
+      wxMenu* menu;
+         
+      wxObject* senderCtrl;
+      int mAscendingID;
+      int mDescendingID;
+      int mFilterID;
+      unsigned int mLastLevel;
+      
+         wxMenu* menuItem;
+         int mAnonymizingID;
+         int mLocalCopyID;
+         int mEditFieldID;
+         
+      // If set to true then OnSelectedChanged returns immediately.
+      // Used to do avoid useless process during multiple selections 
+      // or sorting
+      bool mIgnoreSelectedChanged;
 
 
       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