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
14 class PopupMenuInteractor : public InteractorStyleMaracas , wxEvtHandler
17 PopupMenuInteractor( );
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 // virtual bool OnRightDClick();
27 void OnPopupClick(wxCommandEvent &evt);
29 wxVtkBaseView *_wxvtkbaseview;
33 PopupMenuInteractor::PopupMenuInteractor( )
35 _wxvtkbaseview = NULL;
39 PopupMenuInteractor::PopupMenuInteractor( wxPopupMenu *box , wxVtkBaseView *wxvtkbaseview )
41 _wxvtkbaseview = wxvtkbaseview;
45 PopupMenuInteractor::~PopupMenuInteractor()
49 void PopupMenuInteractor::OnPopupClick(wxCommandEvent &evt)
51 // void *data=static_cast<wxMenu *>(evt.GetEventObject())->GetClientData();
52 // switch( evt.GetId()) {
55 // case ID_SOMETHING_ELSE:
58 int id=evt.GetId()-1000;
59 _box->bbSetOutputOut( id );
60 std::vector<std::string> lstItems = _box->bbGetInputIn();
61 int size = lstItems.size();
62 if ((id>=0) && (id<size))
64 _box->bbSetOutputSimpleText( lstItems[id] );
66 _box->bbSetOutputSimpleText( "void" );
68 _box->bbSignalOutputModification();
71 bool PopupMenuInteractor::OnRightButtonUp()
73 if (_wxvtkbaseview!=NULL)
75 wxWindow *window = _wxvtkbaseview->GetWxVTKRenderWindowInteractor();
76 const wxPoint pt = wxGetMousePosition();
77 int xWindow = pt.x - window->GetScreenPosition().x;
78 int yWindow = pt.y - window->GetScreenPosition().y;
79 std::vector<std::string> lstItems = _box->bbGetInputIn();
80 int size = lstItems.size();
85 wxString itemString( lstItems[i].c_str() , wxConvUTF8 );
86 wxMenuItem *item = menu.Append(i+1000, itemString );
88 menu.Connect( wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction) (wxCommandEventFunction) &PopupMenuInteractor::OnPopupClick,NULL,this );
89 window->PopupMenu(&menu,xWindow,yWindow);
93 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,wxPopupMenu)
94 BBTK_BLACK_BOX_IMPLEMENTATION(wxPopupMenu,bbtk::AtomicBlackBox);
96 // 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)
98 void wxPopupMenu::Process()
101 // THE MAIN PROCESSING METHOD BODY
102 // Here we simply set the input 'In' value to the output 'Out'
103 // And print out the output value
104 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
105 // void bbSet{Input|Output}NAME(const TYPE&)
106 // const TYPE& bbGet{Input|Output}NAME() const
108 // * NAME is the name of the input/output
109 // (the one provided in the attribute 'name' of the tag 'input')
110 // * TYPE is the C++ type of the input/output
111 // (the one provided in the attribute 'type' of the tag 'input')
112 // bbSetOutputOut( bbGetInputIn() );
113 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
117 if (bbGetInputwxVtkBaseView()!=NULL)
119 PopupMenuInteractor* popupmenuinteractor = new PopupMenuInteractor( this, bbGetInputwxVtkBaseView() );
120 vtkInteractorStyleBaseView *vtkinteractorstylebaseview = (vtkInteractorStyleBaseView*) (bbGetInputwxVtkBaseView()->GetInteractorStyleBaseView() );
121 vtkinteractorstylebaseview->AddInteractorStyleMaracas( popupmenuinteractor );
122 } // if wxVtkBaseView
127 // 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)
129 void wxPopupMenu::bbUserSetDefaultValues()
131 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
132 // Here we initialize the input 'In' to 0
134 bbSetInputwxVtkBaseView(NULL);
139 // 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)
141 void wxPopupMenu::bbUserInitializeProcessing()
144 // THE INITIALIZATION METHOD BODY :
146 // but this is where you should allocate the internal/output pointers
152 // 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)
154 void wxPopupMenu::bbUserFinalizeProcessing()
157 // THE FINALIZATION METHOD BODY :
159 // but this is where you should desallocate the internal/output pointers
164 // EO namespace bbcreaMaracasVisu