2 // 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)
4 #include "bbcreaMaracasVisuwxPopupMenu.h"
5 #include "bbcreaMaracasVisuPackage.h"
8 #include "InteractorStyleMaracas.h"
9 #include <vtkInteractorStyleBaseView.h>
11 namespace bbcreaMaracasVisu
15 class PopupMenuInteractor : public InteractorStyleMaracas
18 PopupMenuInteractor( wxPopupMenu *box, wxVtkBaseView *wxvtkbaseview );
19 ~PopupMenuInteractor();
20 // virtual bool OnLeftButtonDown();
21 // virtual bool OnLeftButtonUp();
22 // virtual bool OnMouseMove();
23 // virtual bool OnRightButtonDown();
24 virtual bool OnRightButtonUp();
25 // virtual bool OnLeftDClick();
26 void OnPopupClick(wxCommandEvent &evt);
29 wxVtkBaseView *_wxvtkbaseview;
33 PopupMenuInteractor::PopupMenuInteractor( wxPopupMenu *box , wxVtkBaseView *wxvtkbaseview )
35 _wxvtkbaseview = wxvtkbaseview;
39 PopupMenuInteractor::~PopupMenuInteractor()
43 void PopupMenuInteractor::OnPopupClick(wxCommandEvent &evt)
45 // void *data=static_cast<wxMenu *>(evt.GetEventObject())->GetClientData();
46 // switch( evt.GetId()) {
49 // case ID_SOMETHING_ELSE:
53 printf("EED PopupMenuInteractor::OnPopupClick %d\n", evt.GetId() );
57 bool PopupMenuInteractor::OnRightButtonUp()
59 if (_wxvtkbaseview!=NULL)
61 wxWindow* window = _wxvtkbaseview->GetWxVTKRenderWindowInteractor();
62 const wxPoint pt = wxGetMousePosition();
63 int x = pt.x - window->GetScreenPosition().x;
64 int y = pt.y - window->GetScreenPosition().y;
66 std::vector<std::string> lstItems = _box->bbGetInputIn();
67 int i,size = lstItems.size();
70 menu.Append(i+1000, lstItems[i] );
72 // menu.Connect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(PopupMenuInteractor::OnPopupClick), NULL, this);
73 // Connect( mwxCommandButton->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &CommandButtonWidget::OnCommandButton );
74 menu.Connect( wxEVT_COMMAND_MENU_SELECTED , (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &PopupMenuInteractor::OnPopupClick );
77 window->PopupMenu(&menu,x,y);
84 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,wxPopupMenu)
85 BBTK_BLACK_BOX_IMPLEMENTATION(wxPopupMenu,bbtk::AtomicBlackBox);
87 // 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)
89 void wxPopupMenu::Process()
92 // THE MAIN PROCESSING METHOD BODY
93 // Here we simply set the input 'In' value to the output 'Out'
94 // And print out the output value
95 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
96 // void bbSet{Input|Output}NAME(const TYPE&)
97 // const TYPE& bbGet{Input|Output}NAME() const
99 // * NAME is the name of the input/output
100 // (the one provided in the attribute 'name' of the tag 'input')
101 // * TYPE is the C++ type of the input/output
102 // (the one provided in the attribute 'type' of the tag 'input')
104 // bbSetOutputOut( bbGetInputIn() );
105 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
112 if (bbGetInputwxVtkBaseView()!=NULL)
114 PopupMenuInteractor* popupmenuinteractor = new PopupMenuInteractor( this, bbGetInputwxVtkBaseView() );
115 vtkInteractorStyleBaseView *vtkinteractorstylebaseview = (vtkInteractorStyleBaseView*) (bbGetInputwxVtkBaseView()->GetInteractorStyleBaseView() );
116 vtkinteractorstylebaseview->AddInteractorStyleMaracas( popupmenuinteractor );
117 } // if wxVtkBaseView
122 // 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)
124 void wxPopupMenu::bbUserSetDefaultValues()
127 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
128 // Here we initialize the input 'In' to 0
131 bbSetInputwxVtkBaseView(NULL);
135 // 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)
137 void wxPopupMenu::bbUserInitializeProcessing()
140 // THE INITIALIZATION METHOD BODY :
142 // but this is where you should allocate the internal/output pointers
148 // 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)
150 void wxPopupMenu::bbUserFinalizeProcessing()
153 // THE FINALIZATION METHOD BODY :
155 // but this is where you should desallocate the internal/output pointers
160 // EO namespace bbcreaMaracasVisu