wxMaracasMultipleVolumeRendererView.cxx

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   wxMaracas
00004   Module:    $RCSfile: wxMaracasMultipleVolumeRendererView.cxx,v $
00005   Language:  C++
00006   Date:      $Date: 2010/01/13 13:31:10 $
00007   Version:   $Revision: 1.11 $
00008 
00009   Copyright: (c) 2002, 2003
00010   License:
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notice for more information.
00015 
00016 =========================================================================*/
00017 
00018 
00019 
00020 // EOF - wxMaracasMPR.cxx
00021 
00022 #include "wxMaracasMultipleVolumeRendererView.h"
00023 
00024 
00025 #include <wx/colordlg.h>
00026 #include <wx/bmpbuttn.h> 
00027 
00028 #include <OpenImage.xpm>
00029 #include <Color.xpm>
00030 
00031 wxMaracasMultipleVolumeRendererView* wxMaracasMultipleVolumeRendererView::instance=NULL;
00032 
00033 wxMaracasMultipleVolumeRendererView::wxMaracasMultipleVolumeRendererView( wxWindow* parent,std::string path)
00034 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize){
00035 
00036         wxauimanager = new wxAuiManager(this);
00037 
00038         _path = path;
00039 
00040         volmanager = new wxMaracasMultipleVolumeRendererManager();
00041         std::string iconsdir = path;
00042         iconsdir+="/data/Icons";
00043         this->_toolb = new ToolBarMultipleVolumeRenderer(this,iconsdir);
00044         wxStaticText* txt = new wxStaticText(this, -1, wxString(_T("  Volume Rendering  ")));
00045         wxAuiPaneInfo paneinfo;
00046         wxauimanager->AddPane(txt,paneinfo.ToolbarPane().Top());
00047         wxauimanager->AddPane(_toolb,paneinfo.ToolbarPane().Top());
00048 
00049         wxauimanager->Update(); 
00050 
00051 }
00052 wxMaracasMultipleVolumeRendererView::~wxMaracasMultipleVolumeRendererView( ){
00053 
00054         delete _toolb;
00055 }
00056 
00057 std::string wxMaracasMultipleVolumeRendererView::getPath(){
00058         return _path;
00059 }
00060 
00061 wxMaracasMultipleVolumeRendererView* wxMaracasMultipleVolumeRendererView::getInstance(wxWindow* parent,std::string path){
00062         if(instance==NULL)
00063 {
00064                 instance = new wxMaracasMultipleVolumeRendererView(parent,path);
00065         }
00066         return instance;
00067 }
00068 
00069 wxMaracasMultipleVolumeRendererView* wxMaracasMultipleVolumeRendererView::getInstance(){
00070         return instance;
00071 }
00072 
00073 void wxMaracasMultipleVolumeRendererView::changeCompositeMIPFunction(int id, int function){
00074         try{
00075                 volmanager->changeCompositeMIPFunction(id, function);
00076         }
00077         catch(char* str){
00078                 std::cout << "Exception : " << str << '\n';
00079                 wxMessageDialog* diag = new wxMessageDialog(this, wxString( str,wxConvUTF8 ), wxString( str,wxConvUTF8 ), wxICON_ERROR);
00080                 diag->ShowModal();
00081         }
00082 }
00083 
00084 void wxMaracasMultipleVolumeRendererView::setRenderer(vtkRenderer*  renderer){
00085         volmanager->setRenderer(renderer);
00086 }
00087 
00088 void wxMaracasMultipleVolumeRendererView::addRemoveActor(int id, bool addremove){
00089         try{
00090                 volmanager->addRemoveActor(id, addremove);
00091         }
00092         catch(char* str){
00093                 std::cout << "Exception : " << str << '\n';
00094                 wxMessageDialog* diag = new wxMessageDialog(this, wxString( str,wxConvUTF8 ), wxString( str,wxConvUTF8 ), wxICON_ERROR);
00095                 diag->ShowModal();
00096         }
00097         
00098 }
00099 
00100 void wxMaracasMultipleVolumeRendererView::onLoadImageFile(){
00101 
00102         wxString mhd(_T("mhd"));        
00103 
00104         wxFileDialog* fildial = new wxFileDialog(this, wxString(_T("Select a MHD file")),wxString(_T("")),
00105                 wxString(_T("")),wxString(_T("MHD files (*.mhd)|*.mhd")) );
00106 
00107         if(fildial->ShowModal()==wxID_OK){
00108         wxString filename = fildial->GetFilename();
00109                 wxString pathfile(fildial->GetDirectory() + _T("/") + filename);
00110                 if(filename.EndsWith(mhd)){
00111                         loadVolume(pathfile,filename);
00112                 }
00113         }
00114         delete fildial;
00115 
00116 }
00117 
00118 void wxMaracasMultipleVolumeRendererView::addVolumeViewPanel(wxMaracasMultipleVolumeRendererPanel* irmview, std::string dataname){
00119 
00120         wxString s(dataname.c_str(),wxConvUTF8 );
00121         wxAuiPaneInfo paneinfo;
00122         wxauimanager->AddPane(irmview, paneinfo.DefaultPane().Centre().DestroyOnClose().Caption(s));
00123         wxauimanager->Update();
00124 }
00125         
00126 void wxMaracasMultipleVolumeRendererView::addVolume(vtkImageData* img, std::string dataname){
00127 
00128         try{
00129                 int id = volmanager->addVolume(-1, img,dataname);               
00130                 if(id!=-1){
00131                         wxMaracasMultipleVolumeRendererPanel* controlpan = new wxMaracasMultipleVolumeRendererPanel(this, id,img, false);
00132                         addVolumeViewPanel(controlpan, dataname);
00133                         controlpan->updateVolume();
00134                 }
00135         }catch(char* str){
00136                 std::cout << "Exception : " << str << '\n';
00137                 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
00138                 diag->ShowModal();
00139         }
00140 }
00141 
00142 void wxMaracasMultipleVolumeRendererView::loadVolume(wxString filename, wxString dataname){
00143 
00144         std::string s = std::string(filename.mb_str());
00145         vtkImageData* img = volmanager->getImageData(s);
00146         imgVect.push_back(img);
00147 
00148         if(img!=NULL){
00149                 s = std::string(dataname.mb_str());
00150                 addVolume(img, s);
00151         }
00152 }
00153 
00154 void wxMaracasMultipleVolumeRendererView::deleteVolume(int volid)
00155 {
00156         try{
00157                 volmanager->deleteActor(volid);
00158         }
00159 
00160         catch(char* str){
00161                 std::cout << "Exception : " << str << '\n';
00162                 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
00163                 diag->ShowModal();
00164         }
00165 }
00166 
00167 void wxMaracasMultipleVolumeRendererView::SetValuesColorPointsFunction(int volid, std::vector<double> greylevelcolors,std::vector<double> red,std::vector<double> green,std::vector<double> blue)
00168 {
00169         volmanager->setVolumeColor(volid, greylevelcolors, red, green, blue);
00170 }
00171 void wxMaracasMultipleVolumeRendererView::SetValuesPointsFunction(int volid, std::vector<double> greylevel, std::vector<double> values)
00172 {
00173         volmanager->setVolumeOpacity(volid, greylevel, values);
00174 }
00175 
00176 vtkPiecewiseFunction* wxMaracasMultipleVolumeRendererView::GetTransferFunction(int volumeid)
00177 {
00178         return volmanager->GetTransferFunction(volumeid);
00179 }
00180 vtkColorTransferFunction* wxMaracasMultipleVolumeRendererView::GetColorFunction(int volumeid)
00181 {
00182     return volmanager->GetColorFunction(volumeid);
00183 }
00184 
00185 std::vector<vtkImageData*> wxMaracasMultipleVolumeRendererView::GetOutputImages(){
00186         return imgVect;
00187 }
00188 
00189 wxMaracasMultipleVolumeRendererManager* wxMaracasMultipleVolumeRendererView::getVolumeRenderManager()
00190 {
00191         return volmanager;
00192 }
00193 
00198 ToolBarMultipleVolumeRenderer::ToolBarMultipleVolumeRenderer(wxWindow * parent,std::string iconsdir)
00199 : wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize)
00200 {
00201 
00202 
00203         std::string iconfil = iconsdir;
00204 
00205         //iconfil+= "/OpenImage.png";
00206         //wxBitmap* bitmap0 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
00207         wxBitmap bitmap0(OpenImage_xpm);
00208         this->AddTool(1, wxString(_T("test")),bitmap0, NULL, wxITEM_NORMAL, wxString(_T("Open File")));
00209 
00210         /*iconfil+= "/Open.png";
00211         wxBitmap* bitmap2 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
00212         this->AddTool(2, wxString(_T("test")),*bitmap2);        */
00213 
00214         /*iconfil = iconsdir;
00215         iconfil+= "/Open.png";
00216         wxBitmap* bitmap30 = new wxBitmap(wxString(iconfil.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
00217         this->AddTool(30, wxString(_T("test")),*bitmap30);*/
00218 
00219         this->Realize();
00220 
00221         _evthand = new ToolBarEventHandlerMultipleVolumeRenderer();
00222         this->SetEventHandler(_evthand);
00223 
00224 }
00225 
00226 ToolBarMultipleVolumeRenderer::~ToolBarMultipleVolumeRenderer(void){
00227 }
00228 
00229 ToolBarEventHandlerMultipleVolumeRenderer::ToolBarEventHandlerMultipleVolumeRenderer()
00230 : wxEvtHandler(){
00231 }
00232 ToolBarEventHandlerMultipleVolumeRenderer::~ToolBarEventHandlerMultipleVolumeRenderer(){
00233 }
00234 
00235 void ToolBarEventHandlerMultipleVolumeRenderer::onLoadImageFile(wxCommandEvent& event){
00236         wxMaracasMultipleVolumeRendererView::getInstance()->onLoadImageFile();
00237 }
00238 
00239 
00240 
00241 BEGIN_EVENT_TABLE(ToolBarEventHandlerMultipleVolumeRenderer, wxEvtHandler)
00242         EVT_MENU(1, ToolBarEventHandlerMultipleVolumeRenderer::onLoadImageFile)
00243 END_EVENT_TABLE()
00244 
00245 

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1