From: Eduardo DAVILA Date: Wed, 5 Jan 2022 10:10:22 +0000 (+0100) Subject: #3480 wxPopupMenu box X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=e998861619445a07dd67ed1f651f91c6c7cfcb79;p=creaMaracasVisu.git #3480 wxPopupMenu box --- diff --git a/bbtk/src/bbcreaMaracasVisuwxPopupMenu.cxx b/bbtk/src/bbcreaMaracasVisuwxPopupMenu.cxx new file mode 100644 index 0000000..026a89c --- /dev/null +++ b/bbtk/src/bbcreaMaracasVisuwxPopupMenu.cxx @@ -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 +#include "InteractorStyleMaracas.h" +#include + +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(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 lstItems = _box->bbGetInputIn(); + int i,size = lstItems.size(); + for (i=0;iGetId(), 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 = " <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 index 0000000..bb862c5 --- /dev/null +++ b/bbtk/src/bbcreaMaracasVisuwxPopupMenu.h @@ -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 + + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include +#endif + +#ifdef __WXGTK__ +# include +#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__ + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/InteractorStyleMaracas.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/InteractorStyleMaracas.cxx index d4c495c..311aac2 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/InteractorStyleMaracas.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/InteractorStyleMaracas.cxx @@ -54,7 +54,7 @@ void InteractorStyleMaracas::CopyAttributesTo( InteractorStyleMaracas * cloneObj // Fathers object //::CopyAttributesTo(cloneObject); - cloneObject->SetActive( this->GetActive() ); + cloneObject->SetActive( this->GetActive() ); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/InteractorStyleMaracas.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/InteractorStyleMaracas.h index 165e0c3..349c179 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/InteractorStyleMaracas.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/InteractorStyleMaracas.h @@ -38,40 +38,30 @@ 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; }; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleBaseView3D.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleBaseView3D.h index 5cf8286..6a937c9 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleBaseView3D.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleBaseView3D.h @@ -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_*/