From 7e633c5c02d196b0c8e1b51093ef73896dd29283 Mon Sep 17 00:00:00 2001 From: sebastien valette Date: Fri, 10 Dec 2010 14:34:32 +0000 Subject: [PATCH] wip --- appli/ManualPaint/CMakeLists.txt | 1 + appli/ManualPaint/ManualPaint.cxx | 124 ++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) diff --git a/appli/ManualPaint/CMakeLists.txt b/appli/ManualPaint/CMakeLists.txt index 3ecd1ea..b968c44 100644 --- a/appli/ManualPaint/CMakeLists.txt +++ b/appli/ManualPaint/CMakeLists.txt @@ -20,6 +20,7 @@ INCLUDE_DIRECTORIES(${CREAMARACASVISU_INCLUDE_DIR}) # DEPENDENCIES (LIBRARIES TO LINK WITH) SET ( ${EXE_NAME}_LINK_LIBRARIES ${crea_LIBRARIES} + creaMaracasVisu # ${WXWIDGETS_LIBRARIES} # ${VTK_LIBRARIES} # ${ITK_LIBRARIES} diff --git a/appli/ManualPaint/ManualPaint.cxx b/appli/ManualPaint/ManualPaint.cxx index b7987ad..77c3b16 100644 --- a/appli/ManualPaint/ManualPaint.cxx +++ b/appli/ManualPaint/ManualPaint.cxx @@ -10,6 +10,129 @@ Language: C++ #include "ManualPaintModel.h" #include "wxManualPaintPanel.h" +#include "wx/wx.h" + +class MyApp; +class MyFrame; + +// Define a new application type, each program should derive a class from wxApp +class MyApp : public wxApp +{ +public: + // this one is called on application startup and is a good place for the app + // initialization (doing it here and not in the ctor allows to have an error + // return: if OnInit() returns false, the application terminates) + virtual bool OnInit(); +}; + +// Define a new frame type: this is going to be our main frame +class MyFrame : public wxFrame +{ +public: + // ctor(s) + MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size); + ~MyFrame(); + + // event handlers (these functions should _not_ be virtual) + void OnQuit(wxCommandEvent& event); + +private: + +// wxRenderWindow *MyRenderWindow; + + +private: + // any class wishing to process wxWindows events must use this macro + DECLARE_EVENT_TABLE() +}; + +// IDs for the controls and the menu commands +enum +{ + // menu items + Minimal_Quit = 1, + Minimal_About +}; + +#define MY_FRAME 101 +#define MY_VTK_WINDOW 102 + +// the event tables connect the wxWindows events with the functions (event +// handlers) which process them. It can be also done at run-time, but for the +// simple menu events like this the static method is much simpler. +BEGIN_EVENT_TABLE(MyFrame, wxFrame) + EVT_MENU(Minimal_Quit, MyFrame::OnQuit) +END_EVENT_TABLE() + +// Create a new application object: this macro will allow wxWindows to create +// the application object during program execution (it's better than using a +// static object for many reasons) and also declares the accessor function +// wxGetApp() which will return the reference of the right type (i.e. MyApp and +// not wxApp) +IMPLEMENT_APP(MyApp) + +// 'Main program' equivalent: the program execution "starts" here +bool MyApp::OnInit() +{ + // create the main application window + MyFrame *frame = new MyFrame(_T("wxWindows-VTK App"), + wxPoint(50, 50), wxSize(450, 340)); + + // and show it (the frames, unlike simple controls, are not shown when + // created initially) + frame->Show(TRUE); + + + + // success: wxApp::OnRun() will be called which will enter the main message + // loop and the application will run. If we returned FALSE here, the + // application would exit immediately. + return TRUE; +} + +// frame constructor +MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) + : wxFrame((wxFrame *)NULL, -1, title, pos, size) +{ + + vtkMetaImageReader *Reader=vtkMetaImageReader::New(); +// Reader->SetFileName(argv[1]); + Reader->SetFileName("/home/valette/sphere.mhd"); + Reader->Update(); + + + ManualPaintModel *mpModel = new ManualPaintModel; + mpModel->SetImage(Reader->GetOutput()); + + wxManualPaintPanel *mpPanel = new wxManualPaintPanel(this); + mpPanel->SetManualPaintModel(mpModel); +/* + MyRenderWindow=wxRenderWindow::New(this, MY_VTK_WINDOW); + + vtkConeSource *pConeSource; + pConeSource = vtkConeSource::New(); + pConeSource->SetResolution(800); + + MyRenderWindow->SetInput(pConeSource->GetOutput()); + pConeSource->Delete(); + RenderWindowWidgets *RWidgets= new RenderWindowWidgets(this, 1000,wxPanelNameStr, + wxDefaultPosition,wxDefaultSize,wxWANTS_CHARS | wxNO_FULL_REPAINT_ON_RESIZE); + RWidgets->Show(TRUE);*/ + +} + +MyFrame::~MyFrame() +{ +} + +// event handlers + +void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +{ + // TRUE is to force the frame to close + Close(TRUE); +} +/* int main( int argc, char *argv[] ) { @@ -27,3 +150,4 @@ int main( int argc, char *argv[] ) return (0); } +*/ -- 2.45.1