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>
10 #include "wxVtk2DBaseView.h"
12 namespace bbcreaMaracasVisu
15 class PopupMenuInteractor : public InteractorStyleMaracas , wxEvtHandler
18 // PopupMenuInteractor( );
19 PopupMenuInteractor( wxPopupMenu *box, wxVtkBaseView *wxvtkbaseview );
20 ~PopupMenuInteractor();
21 // virtual bool OnLeftButtonDown();
22 // virtual bool OnLeftButtonUp();
23 // virtual bool OnMouseMove();
24 // virtual bool OnRightButtonDown();
25 virtual bool OnRightButtonUp();
26 // virtual bool OnLeftDClick();
27 // virtual bool OnRightDClick();
28 void OnPopupClick(wxCommandEvent &evt);
30 wxVtkBaseView *_wxvtkbaseview;
32 std::vector<double> lstPoint;
36 PopupMenuInteractor::PopupMenuInteractor( )
38 _wxvtkbaseview = NULL;
42 PopupMenuInteractor::PopupMenuInteractor( wxPopupMenu *box , wxVtkBaseView *wxvtkbaseview )
44 _wxvtkbaseview = wxvtkbaseview;
48 PopupMenuInteractor::~PopupMenuInteractor()
52 void PopupMenuInteractor::OnPopupClick(wxCommandEvent &evt)
54 // void *data=static_cast<wxMenu *>(evt.GetEventObject())->GetClientData();
55 // switch( evt.GetId()) {
58 // case ID_SOMETHING_ELSE:
61 int id=evt.GetId()-1000;
62 _box->bbSetOutputOut( id );
63 std::vector<std::string> lstItems = _box->bbGetInputIn();
64 int size = lstItems.size();
65 if ((id>=0) && (id<size))
67 _box->bbSetOutputSimpleText( lstItems[id] );
69 _box->bbSetOutputSimpleText( "void" );
71 _box->bbSetOutputPoint( lstPoint );
72 _box->bbSignalOutputModification();
75 bool PopupMenuInteractor::OnRightButtonUp()
77 if (_wxvtkbaseview!=NULL)
79 wxWindow *window = _wxvtkbaseview->GetWxVTKRenderWindowInteractor();
80 const wxPoint pt = wxGetMousePosition();
81 int xWindow = pt.x - window->GetScreenPosition().x;
82 int yWindow = pt.y - window->GetScreenPosition().y;
83 std::vector<std::string> lstItems = _box->bbGetInputIn();
84 int size = lstItems.size();
90 crea::wxVTKRenderWindowInteractor *wxVTKiren;
91 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
92 wxVTKiren->GetEventPosition(X,Y);
93 Z = (int)((wxVtk2DBaseView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()))->GetVtkBaseData()->GetZ();
97 _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->TransFromCoordScreenToWorld(dxx,dyy,dzz,true);
100 _pz = (int)(dzz+0.0);
103 ((wxVtk2DBaseView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()))->GetVtkBaseData()->GetPointMouse(x,y,z);
105 lstPoint.push_back(x);
106 lstPoint.push_back(y);
107 lstPoint.push_back(z);
111 wxString itemString( lstItems[i].c_str() , wxConvUTF8 );
112 wxMenuItem *item = menu.Append(i+1000, itemString );
114 menu.Connect( wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction) (wxCommandEventFunction) &PopupMenuInteractor::OnPopupClick,NULL,this );
115 window->PopupMenu(&menu,xWindow,yWindow);
119 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,wxPopupMenu)
120 BBTK_BLACK_BOX_IMPLEMENTATION(wxPopupMenu,bbtk::AtomicBlackBox);
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::Process()
126 // THE MAIN PROCESSING METHOD BODY
127 // Here we simply set the input 'In' value to the output 'Out'
128 // And print out the output value
129 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
130 // void bbSet{Input|Output}NAME(const TYPE&)
131 // const TYPE& bbGet{Input|Output}NAME() const
133 // * NAME is the name of the input/output
134 // (the one provided in the attribute 'name' of the tag 'input')
135 // * TYPE is the C++ type of the input/output
136 // (the one provided in the attribute 'type' of the tag 'input')
137 // bbSetOutputOut( bbGetInputIn() );
138 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
142 if (bbGetInputwxVtkBaseView()!=NULL)
144 PopupMenuInteractor* popupmenuinteractor = new PopupMenuInteractor( this, bbGetInputwxVtkBaseView() );
145 vtkInteractorStyleBaseView *vtkinteractorstylebaseview = (vtkInteractorStyleBaseView*) (bbGetInputwxVtkBaseView()->GetInteractorStyleBaseView() );
146 vtkinteractorstylebaseview->AddInteractorStyleMaracas( popupmenuinteractor );
147 } // if wxVtkBaseView
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::bbUserSetDefaultValues()
156 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
157 // Here we initialize the input 'In' to 0
159 bbSetInputwxVtkBaseView(NULL);
164 // 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)
166 void wxPopupMenu::bbUserInitializeProcessing()
168 // THE INITIALIZATION METHOD BODY :
170 // but this is where you should allocate the internal/output pointers
175 // 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)
177 void wxPopupMenu::bbUserFinalizeProcessing()
179 // THE FINALIZATION METHOD BODY :
181 // but this is where you should desallocate the internal/output pointers
185 }// EO namespace bbcreaMaracasVisu