]> Creatis software - creaMaracasVisu.git/commitdiff
#3480 wxPopupMenu box
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Wed, 5 Jan 2022 10:10:22 +0000 (11:10 +0100)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Wed, 5 Jan 2022 10:10:22 +0000 (11:10 +0100)
bbtk/src/bbcreaMaracasVisuwxPopupMenu.cxx [new file with mode: 0644]
bbtk/src/bbcreaMaracasVisuwxPopupMenu.h [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/widgets/InteractorStyleMaracas.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/InteractorStyleMaracas.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleBaseView3D.h

diff --git a/bbtk/src/bbcreaMaracasVisuwxPopupMenu.cxx b/bbtk/src/bbcreaMaracasVisuwxPopupMenu.cxx
new file mode 100644 (file)
index 0000000..026a89c
--- /dev/null
@@ -0,0 +1,162 @@
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+#include "bbcreaMaracasVisuwxPopupMenu.h"
+#include "bbcreaMaracasVisuPackage.h"
+
+#include <wx/menu.h>
+#include "InteractorStyleMaracas.h"
+#include <vtkInteractorStyleBaseView.h>
+
+namespace bbcreaMaracasVisu
+{
+
+
+class PopupMenuInteractor : public InteractorStyleMaracas
+{
+public:
+    PopupMenuInteractor( wxPopupMenu *box, wxVtkBaseView *wxvtkbaseview );
+    ~PopupMenuInteractor();
+//    virtual bool  OnLeftButtonDown();
+//    virtual bool  OnLeftButtonUp();
+//    virtual bool  OnMouseMove();
+//        virtual bool  OnRightButtonDown();
+    virtual bool  OnRightButtonUp();
+//    virtual bool  OnLeftDClick();
+    void OnPopupClick(wxCommandEvent &evt);
+
+private:
+    wxVtkBaseView   *_wxvtkbaseview;
+    wxPopupMenu     *_box;
+};
+
+PopupMenuInteractor::PopupMenuInteractor( wxPopupMenu *box , wxVtkBaseView *wxvtkbaseview )
+{
+    _wxvtkbaseview = wxvtkbaseview;
+    _box           = box;
+}
+
+PopupMenuInteractor::~PopupMenuInteractor()
+{
+}
+
+void PopupMenuInteractor::OnPopupClick(wxCommandEvent &evt)
+{
+//    void *data=static_cast<wxMenu *>(evt.GetEventObject())->GetClientData();
+//    switch( evt.GetId()) {
+//        case ID_SOMETHING:
+//            break;
+//        case ID_SOMETHING_ELSE:
+//            break;
+//    }
+    
+    printf("EED PopupMenuInteractor::OnPopupClick %d\n", evt.GetId() );
+    
+}
+
+bool PopupMenuInteractor::OnRightButtonUp()
+{
+    if (_wxvtkbaseview!=NULL)
+    {
+        wxWindow* window = _wxvtkbaseview->GetWxVTKRenderWindowInteractor();
+        const wxPoint pt = wxGetMousePosition();
+        int x = pt.x - window->GetScreenPosition().x;
+        int y = pt.y - window->GetScreenPosition().y;
+        wxMenu  menu;
+        std::vector<std::string> lstItems = _box->bbGetInputIn();
+        int i,size = lstItems.size();
+        for (i=0;i<size;i++)
+        {
+            menu.Append(i+1000, lstItems[i] );
+        } // for
+//      menu.Connect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(PopupMenuInteractor::OnPopupClick), NULL, this);
+//      Connect( mwxCommandButton->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction)  (void (wxPanel::*)(wxEvent&)) &CommandButtonWidget::OnCommandButton );
+        menu.Connect(   wxEVT_COMMAND_MENU_SELECTED , (wxObjectEventFunction)  (void (wxPanel::*)(wxEvent&)) &PopupMenuInteractor::OnPopupClick );
+
+        
+        window->PopupMenu(&menu,x,y);
+    } // if _vtkbaseview
+}
+
+
+
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,wxPopupMenu)
+BBTK_BLACK_BOX_IMPLEMENTATION(wxPopupMenu,bbtk::AtomicBlackBox);
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+void wxPopupMenu::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+//   Here we simply set the input 'In' value to the output 'Out'
+//   And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+//    void bbSet{Input|Output}NAME(const TYPE&)
+//    const TYPE& bbGet{Input|Output}NAME() const 
+//    Where :
+//    * NAME is the name of the input/output
+//      (the one provided in the attribute 'name' of the tag 'input')
+//    * TYPE is the C++ type of the input/output
+//      (the one provided in the attribute 'type' of the tag 'input')
+    
+//    bbSetOutputOut( bbGetInputIn() );
+//    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
+      
+    
+    if (firsttime==true)
+    {
+        firsttime=false;
+        
+        if (bbGetInputwxVtkBaseView()!=NULL)
+        {
+            PopupMenuInteractor* popupmenuinteractor = new PopupMenuInteractor( this, bbGetInputwxVtkBaseView()  );
+            vtkInteractorStyleBaseView *vtkinteractorstylebaseview = (vtkInteractorStyleBaseView*) (bbGetInputwxVtkBaseView()->GetInteractorStyleBaseView() );
+            vtkinteractorstylebaseview->AddInteractorStyleMaracas( popupmenuinteractor );
+        } // if wxVtkBaseView
+    } // if firsttime
+    
+}
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+void wxPopupMenu::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
+//    Here we initialize the input 'In' to 0
+
+    firsttime=true;
+    bbSetInputwxVtkBaseView(NULL);
+  
+}
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+void wxPopupMenu::bbUserInitializeProcessing()
+{
+
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should allocate the internal/output pointers 
+//    if any 
+
+  
+}
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+void wxPopupMenu::bbUserFinalizeProcessing()
+{
+
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should desallocate the internal/output pointers 
+//    if any
+  
+}
+}
+// EO namespace bbcreaMaracasVisu
+
+
diff --git a/bbtk/src/bbcreaMaracasVisuwxPopupMenu.h b/bbtk/src/bbcreaMaracasVisuwxPopupMenu.h
new file mode 100644 (file)
index 0000000..bb862c5
--- /dev/null
@@ -0,0 +1,76 @@
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+#ifndef __bbcreaMaracasVisuwxPopupMenu_h_INCLUDED__
+#define __bbcreaMaracasVisuwxPopupMenu_h_INCLUDED__
+
+#include "bbcreaMaracasVisu_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+#include <wx/datetime.h>
+
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include <wx/wx.h>
+#endif
+
+#ifdef __WXGTK__
+# include <locale.h>
+#endif //__WXGTK__
+// EO Wx headers
+
+#include "wxVtkBaseView.h"
+
+
+
+namespace bbcreaMaracasVisu
+{
+
+class bbcreaMaracasVisu_EXPORT wxPopupMenu
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(wxPopupMenu,bbtk::AtomicBlackBox);
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+    BBTK_DECLARE_INPUT(In,std::vector< std::string >);
+    BBTK_DECLARE_INPUT(wxVtkBaseView,wxVtkBaseView*);
+//    BBTK_DECLARE_INPUT(Position,std::vector< int >);
+    BBTK_DECLARE_OUTPUT(Out,int);
+    BBTK_DECLARE_OUTPUT(SimpleText,std::string);
+    BBTK_PROCESS(Process);
+    void Process();
+    bool firsttime;
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(wxPopupMenu,bbtk::AtomicBlackBox);
+    BBTK_NAME("wxPopupMenu");
+    BBTK_AUTHOR("InfoDev");
+    BBTK_DESCRIPTION("No Description.");
+    BBTK_CATEGORY("empty");
+    BBTK_INPUT(wxPopupMenu,In,"Vector of items",std::vector< std::string >,"");
+//    BBTK_INPUT(wxPopupMenu,Position,"Window position",std::vector< int >,"");
+    BBTK_INPUT(wxPopupMenu,wxVtkBaseView,"wxVtkBaseView",wxVtkBaseView*,"");
+    BBTK_OUTPUT(wxPopupMenu,Out,"Sected item",int,"");
+    BBTK_OUTPUT(wxPopupMenu,SimpleText,"Text selected item",std::string,"");
+BBTK_END_DESCRIBE_BLACK_BOX(wxPopupMenu);
+//===== 
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//===== 
+}
+// EO namespace bbcreaMaracasVisu
+
+#endif // __bbcreaMaracasVisuwxPopupMenu_h_INCLUDED__
+
index d4c495c85083681b833b4fe56aabebf43223a077..311aac246c2c60f147f68de0983c7da6283f292b 100644 (file)
@@ -54,7 +54,7 @@ void InteractorStyleMaracas::CopyAttributesTo( InteractorStyleMaracas * cloneObj
        // Fathers object
        //<FATHERCLASS>::CopyAttributesTo(cloneObject);
 
-       cloneObject->SetActive(  this->GetActive() );
+       cloneObject->SetActive( this->GetActive() );
 }
 
 
index 165e0c3706f90bd7b007e177c286ae6f98f47d83..349c1790fdf8de30f0fd14acb5b8daba50a7843b 100644 (file)
 class creaMaracasVisu_EXPORT InteractorStyleMaracas 
 {
 public:
-       InteractorStyleMaracas();
-       virtual ~InteractorStyleMaracas();
-
-       virtual InteractorStyleMaracas * Clone();
-       void CopyAttributesTo( InteractorStyleMaracas *cloneObject );
-
-
-       virtual bool  OnChar();
-       virtual bool  OnMouseMove();
-       virtual bool  OnLeftButtonDown(); 
-       virtual bool  OnLeftButtonUp();
-       virtual bool  OnMiddleButtonDown(); 
-       virtual bool  OnMiddleButtonUp();
-       virtual bool  OnRightButtonDown();
-       virtual bool  OnRightButtonUp();
-
-       virtual bool  OnLeftDClick();
-       virtual bool  OnRightDClick();   
-       virtual bool  OnMiddleDClick();  
-               
-       virtual bool  OnMouseWheelForward();
-       virtual bool  OnMouseWheelBackward();
-       
-       void  SetVtkInteractorStyleBaseView(vtkInteractorStyleBaseView* _vtkInteractorStyleBaseView);   
-       void  RemoveVtkInteractorStyleBaseView();
-       
-       void SetActive(bool active);
-       bool GetActive();
-
+                    InteractorStyleMaracas();
+       virtual         ~InteractorStyleMaracas();
+       virtual         InteractorStyleMaracas * Clone();
+       void            CopyAttributesTo( InteractorStyleMaracas *cloneObject );
+       virtual bool    OnChar();
+       virtual bool    OnMouseMove();
+       virtual bool    OnLeftButtonDown();
+       virtual bool    OnLeftButtonUp();
+       virtual bool    OnMiddleButtonDown();
+       virtual bool    OnMiddleButtonUp();
+       virtual bool    OnRightButtonDown();
+       virtual bool    OnRightButtonUp();
+       virtual bool    OnLeftDClick();
+       virtual bool    OnRightDClick();
+       virtual bool    OnMiddleDClick();
+       virtual bool    OnMouseWheelForward();
+       virtual bool    OnMouseWheelBackward();
+       void            SetVtkInteractorStyleBaseView(vtkInteractorStyleBaseView* _vtkInteractorStyleBaseView);
+       void            RemoveVtkInteractorStyleBaseView();
+       void            SetActive(bool active);
+       bool            GetActive();
 protected:
-       
        vtkInteractorStyleBaseView* _vtkInteractorStyleBaseView;         
        //vtkInteractorStyleImage* _vtkInteractorStyleBaseView;
-       
 private:
        bool                                            _active;
 };
index 5cf8286bc07fd8ddab0f866ac39e7b42f462038a..6a937c9f9e3bfe3d482b9db34902ba52db26c721 100644 (file)
@@ -37,19 +37,16 @@ public:
        vtkInteractorStyleBaseView3D();
        ~vtkInteractorStyleBaseView3D();
        static vtkInteractorStyleBaseView3D *New();
-
-       virtual void  OnMouseMove () ;
-       virtual void  OnLeftButtonDown (); 
-       virtual void  OnLeftButtonUp () ;
-       virtual void  OnMiddleButtonDown (); 
-       virtual void  OnMiddleButtonUp () ;
-       virtual void  OnRightButtonDown () ;
-       virtual void  OnRightButtonUp () ;
+       virtual void OnMouseMove () ;
+       virtual void OnLeftButtonDown ();
+       virtual void OnLeftButtonUp () ;
+       virtual void OnMiddleButtonDown ();
+       virtual void OnMiddleButtonUp () ;
+       virtual void OnRightButtonDown () ;
+       virtual void OnRightButtonUp () ;
        virtual void OnMouseWheelForward();
        virtual void OnMouseWheelBackward();
-
 private:
-
 };
 
 #endif /*VTKINTERACTORSTYLEBASEVIEW3D_H_*/